Module: CassandraObject::AttributeMethods::Dirty
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActiveModel::Dirty
- Included in:
- Base
- Defined in:
- lib/cassandra_object/attribute_methods/dirty.rb
Instance Method Summary collapse
-
#reload ⇒ Object
reload
the record and clears changed attributes. -
#save ⇒ Object
Attempts to
save
the record and clears changed attributes if successful. - #write_attribute(name, value) ⇒ Object
Instance Method Details
#reload ⇒ Object
reload
the record and clears changed attributes.
17 18 19 20 21 22 |
# File 'lib/cassandra_object/attribute_methods/dirty.rb', line 17 def reload super.tap do @previously_changed.try :clear @changed_attributes.try :clear end end |
#save ⇒ Object
Attempts to save
the record and clears changed attributes if successful.
8 9 10 11 12 13 14 |
# File 'lib/cassandra_object/attribute_methods/dirty.rb', line 8 def save(*) #:nodoc: if status = super @previously_changed = changes @changed_attributes = {} end status end |
#write_attribute(name, value) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cassandra_object/attribute_methods/dirty.rb', line 24 def write_attribute(name, value) name = name.to_s old = read_attribute(name) super unless attribute_changed?(name) || old == read_attribute(name) changed_attributes[name] = old end end |