Module: Mongoid::Dirty
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActiveModel::Dirty
- Included in:
- Components
- Defined in:
- lib/mongoid/dirty.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#move_changes ⇒ Object
Call this method after save, so the changes can be properly switched.
-
#remove_change(name) ⇒ Object
Remove a change from the dirty attributes hash.
-
#setters ⇒ Hash
Gets all the new values for each of the changed fields, to be passed to a MongoDB $set modifier.
Instance Method Details
#move_changes ⇒ Object
Call this method after save, so the changes can be properly switched.
This will unset the memoized children array, set new record to false, set the document as validated, and move the dirty changes.
16 17 18 19 20 21 22 23 24 |
# File 'lib/mongoid/dirty.rb', line 16 def move_changes @_children = nil @previously_changed = changes atomic_pulls.clear atomic_unsets.clear delayed_atomic_sets.clear delayed_atomic_pulls.clear changed_attributes.clear end |
#remove_change(name) ⇒ Object
Remove a change from the dirty attributes hash. Used by the single field atomic updators.
35 36 37 |
# File 'lib/mongoid/dirty.rb', line 35 def remove_change(name) changed_attributes.delete(name.to_s) end |
#setters ⇒ Hash
Gets all the new values for each of the changed fields, to be passed to a MongoDB $set modifier.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/mongoid/dirty.rb', line 48 def setters {}.tap do |modifications| changes.each_pair do |field, changes| if changes key = ? "#{atomic_position}.#{field}" : field modifications[key] = changes[1] end end end end |