Module: Mongoid::Persistence::Modification
- Included in:
- Operations::Update
- Defined in:
- lib/mongoid/persistence/modification.rb
Overview
Contains common logic for modification operations.
Instance Method Summary collapse
-
#prepare(&block) ⇒ true, false
Wrap all the common modification logic for both root and embedded documents and then yield to the block.
Instance Method Details
#prepare(&block) ⇒ true, false
Wrap all the common modification logic for both root and embedded documents and then yield to the block.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mongoid/persistence/modification.rb', line 21 def prepare(&block) return false if validating? && document.invalid?(:update) document.run_callbacks(:save) do document.run_callbacks(:update) do yield(document); true end end.tap do |result| unless result == false document.reset_persisted_children document.move_changes Threaded. end end end |