Module: Mongoid::Persistence::Upsertion
- Included in:
- Operations::Upsert
- Defined in:
- lib/mongoid/persistence/upsertion.rb
Overview
Contains common logic for upsert operations.
Instance Method Summary collapse
-
#prepare(&block) ⇒ true, false
Wrap all the common upsert logic for root docments.
Instance Method Details
#prepare(&block) ⇒ true, false
Wrap all the common upsert logic for root docments.
20 21 22 23 24 25 26 27 28 |
# File 'lib/mongoid/persistence/upsertion.rb', line 20 def prepare(&block) return false if validating? && document.invalid?(:upsert) result = document.run_callbacks(:upsert) do yield(document); true end document.post_persist unless result == false document.new_record = false result end |