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. -
#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.
25 26 27 28 29 30 |
# File 'lib/cassandra_object/attribute_methods/dirty.rb', line 25 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.clear end status end |
#save! ⇒ Object
Attempts to save!
the record and clears changed attributes if successful.
17 18 19 20 21 22 |
# File 'lib/cassandra_object/attribute_methods/dirty.rb', line 17 def save!(*) #:nodoc: super.tap do @previously_changed = changes @changed_attributes.clear end end |
#write_attribute(name, value) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cassandra_object/attribute_methods/dirty.rb', line 32 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 |