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 |
# File 'lib/mongoid/persistence/modification.rb', line 21 def prepare(&block) return false if validating? && document.invalid?(:update) document.process_flagged_destroys result = document.run_callbacks(:save) do document.run_callbacks(:update) do yield(document); true end end document.post_persist unless result == false document.errors.clear unless validating? result end |