Module: MassiveRecord::ORM::AttributeMethods::Dirty
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActiveModel::Dirty
- Defined in:
- lib/massive_record/orm/attribute_methods/dirty.rb
Instance Method Summary collapse
Instance Method Details
#reload ⇒ Object
26 27 28 29 30 |
# File 'lib/massive_record/orm/attribute_methods/dirty.rb', line 26 def reload(*) super.tap do clear_dirty_states! end end |
#save ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/massive_record/orm/attribute_methods/dirty.rb', line 9 def save(*) if status = super changes_before_save = changes clear_dirty_states! @previously_changed = changes_before_save end status end |
#save! ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/massive_record/orm/attribute_methods/dirty.rb', line 18 def save!(*) super.tap do changes_before_save = changes clear_dirty_states! @previously_changed = changes_before_save end end |
#write_attribute(attr_name, value) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/massive_record/orm/attribute_methods/dirty.rb', line 32 def write_attribute(attr_name, value) attr_name = attr_name.to_s if will_change_attribute?(attr_name, value) if will_change_back_to_original_value?(attr_name, value) changed_attributes.delete(attr_name) else super(attr_name, original_attribute_value(attr_name)) send("#{attr_name}_will_change!") end end super end |