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)
- - (Object) clear_changes
- - (Object) reload
- - (Object) save
- - (Object) update!
- - (Object) write_attribute(name, value)
Instance Method Details
- (Object) clear_changes
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 |
- (Object) reload
22 23 24 |
# File 'lib/dynamoid/dirty.rb', line 22 def reload super.tap { clear_changes } end |
- (Object) save
12 13 14 |
# File 'lib/dynamoid/dirty.rb', line 12 def save(*) clear_changes { super } end |
- (Object) update!
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 |
- (Object) write_attribute(name, value)
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 |