This is the included module for all atomic operation objects.
Get the collection to be used for persistence.
@example Get the collection.
operation.collection
@return [ Collection ] The root collection.
@since 2.1.0
# File lib/mongoid/persistence/atomic/operation.rb, line 18 def collection document._root.collection end
Get the atomic operation to perform.
@example Get the operation.
inc.operation
@param [ String ] modifier The modifier to use.
@return [ Hash ] The atomic operation for the field and addition.
@since 2.0.0
# File lib/mongoid/persistence/atomic/operation.rb, line 48 def operation(modifier) { modifier => { path => value } } end
Get the path to the field that is getting atomically updated.
@example Get the path.
operation.path
@return [ String, Symbol ] The path to the field.
@since 2.1.0
# File lib/mongoid/persistence/atomic/operation.rb, line 60 def path position = document.atomic_position position.blank? ? field : "#{position}.#{field}" end
All atomic operations use this with a block to ensure saftey options clear out after the execution.
@example Prepare the operation.
prepare do collection.update end
@return [ Object ] The yielded value.
@since 2.1.0
# File lib/mongoid/persistence/atomic/operation.rb, line 76 def prepare yield(document).tap do Threaded.clear_options! end end
Initialize the new pullAll operation.
@example Create a new pullAll operation.
PullAll.new(document, :aliases, [ "Bond" ])
@param [ Document ] document The document to pullAll onto. @param [ Symbol ] field The name of the array field. @param [ Object ] value The value to pullAll. @param [ Hash ] options The persistence options.
@since 2.0.0
# File lib/mongoid/persistence/atomic/operation.rb, line 33 def initialize(document, field, value, options = {}) @document, @field, @value = document, field.to_s, value @options = Safety.merge_safety_options(options) end
Generated with the Darkfish Rdoc Generator 2.