Module: Dynamoid::Dirty
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActiveModel::Dirty
- Included in:
- Components
- Defined in:
- lib/dynamoid/dirty.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #clear_changes ⇒ Object
- #reload ⇒ Object
- #save ⇒ Object
- #update! ⇒ Object
- #write_attribute(name, value) ⇒ Object
Instance Method Details
#clear_changes ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/dynamoid/dirty.rb', line 26 def clear_changes previous = changes (block_given? ? yield : true).tap do |result| unless result == false #failed validation; nil is OK. @previously_changed = previous changed_attributes.clear end end end |
#reload ⇒ Object
22 23 24 |
# File 'lib/dynamoid/dirty.rb', line 22 def reload super.tap { clear_changes } end |
#save ⇒ Object
12 13 14 |
# File 'lib/dynamoid/dirty.rb', line 12 def save(*) clear_changes { super } end |
#update! ⇒ Object
16 17 18 19 20 |
# File 'lib/dynamoid/dirty.rb', line 16 def update!(*) ret = super clear_changes #update! completely reloads all fields on the class, so any extant changes are wiped out ret end |
#write_attribute(name, value) ⇒ Object
36 37 38 39 |
# File 'lib/dynamoid/dirty.rb', line 36 def write_attribute(name, value) attribute_will_change!(name) unless self.read_attribute(name) == value super end |