Module: Mongoid::Locking::Contextual::Mongo
- Defined in:
- lib/mongoid/locking/contextual/mongo.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#update_documents(attributes, method = :update_one, opts = {}) ⇒ true, false
private
Update the documents for the provided method.
Instance Method Details
#update_documents(attributes, method = :update_one, opts = {}) ⇒ true, false
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Update the documents for the provided method.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mongoid/locking/contextual/mongo.rb', line 17 def update_documents(attributes, method = :update_one, opts = {}) return false unless attributes attributes = Hash[attributes.transform_keys { |k| klass.database_field_name(k.to_s) }] updates = attributes.__consolidate__(klass) if _locking? updates["$inc"] ||= {} updates["$inc"]["lock_version"] = 1 end view.send(method, updates, opts) end |