Class: Mongoid::Persistence::Operations::Upsert
- Inherits:
-
Object
- Object
- Mongoid::Persistence::Operations::Upsert
- Includes:
- Mongoid::Persistence::Operations, Upsertion
- Defined in:
- lib/mongoid/persistence/operations/upsert.rb
Overview
Wraps behaviour for performing upserts in Mongodb. No matter if the document has been modified or not, it will be sent to the db and Mongo will determin whether or not to insert or update.
Instance Attribute Summary
Attributes included from Mongoid::Persistence::Operations
#conflicts, #document, #options
Instance Method Summary collapse
-
#persist ⇒ true
Persist the upsert operation.
Methods included from Upsertion
Methods included from Mongoid::Persistence::Operations
#collection, #deletes, #initialize, insert, #inserts, #notifying_parent?, #parent, remove, #selector, update, #updates, upsert, #validating?
Instance Method Details
#persist ⇒ true
Persist the upsert operation.
20 21 22 23 24 |
# File 'lib/mongoid/persistence/operations/upsert.rb', line 20 def persist prepare do collection.find(selector).update(document.as_document, [ :upsert ]) end end |