Module: Mongoid::Persistence::Atomic::Operation
- Defined in:
- lib/mongoid/persistence/atomic/operation.rb
Overview
This is the included module for all atomic operation objects.
Instance Attribute Summary collapse
-
#document ⇒ Object
Returns the value of attribute document.
-
#field ⇒ Object
Returns the value of attribute field.
-
#options ⇒ Object
Returns the value of attribute options.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#collection ⇒ Collection
Get the collection to be used for persistence.
-
#initialize(document, field, value, options = {}) ⇒ Object
Initialize the new pullAll operation.
-
#operation(modifier) ⇒ Hash
Get the atomic operation to perform.
-
#path ⇒ String, Symbol
Get the path to the field that is getting atomically updated.
-
#prepare ⇒ Object
All atomic operations use this with a block to ensure saftey options clear out after the execution.
Instance Attribute Details
#document ⇒ Object
Returns the value of attribute document.
9 10 11 |
# File 'lib/mongoid/persistence/atomic/operation.rb', line 9 def document @document end |
#field ⇒ Object
Returns the value of attribute field.
9 10 11 |
# File 'lib/mongoid/persistence/atomic/operation.rb', line 9 def field @field end |
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/mongoid/persistence/atomic/operation.rb', line 9 def @options end |
#value ⇒ Object
Returns the value of attribute value.
9 10 11 |
# File 'lib/mongoid/persistence/atomic/operation.rb', line 9 def value @value end |
Instance Method Details
#collection ⇒ Collection
Get the collection to be used for persistence.
19 20 21 |
# File 'lib/mongoid/persistence/atomic/operation.rb', line 19 def collection document._root.collection end |
#initialize(document, field, value, options = {}) ⇒ Object
Initialize the new pullAll operation.
34 35 36 37 |
# File 'lib/mongoid/persistence/atomic/operation.rb', line 34 def initialize(document, field, value, = {}) @document, @field, @value = document, field.to_s, value @options = Safety.() end |
#operation(modifier) ⇒ Hash
Get the atomic operation to perform.
49 50 51 |
# File 'lib/mongoid/persistence/atomic/operation.rb', line 49 def operation(modifier) { modifier => { path => value } } end |