Class: Mongoid::Relations::Embedded::Atomic::Operation
- Defined in:
- lib/mongoid/relations/embedded/atomic/operation.rb
Instance Attribute Summary collapse
-
#documents ⇒ Object
Returns the value of attribute documents.
-
#options ⇒ Object
Returns the value of attribute options.
-
#path ⇒ Object
Returns the value of attribute path.
-
#selector ⇒ Object
Returns the value of attribute selector.
Instance Method Summary collapse
-
#consume(selector, operations, options = {}) ⇒ Object
Consumes an execution that was supposed to hit the database, but is now being deferred to later in favor of a single update.
-
#consumed? ⇒ true, false
Has this operation consumed any executions?.
-
#execute(collection) ⇒ Object
Execute the $pushAll operation on the collection.
Instance Attribute Details
#documents ⇒ Object
Returns the value of attribute documents.
8 9 10 |
# File 'lib/mongoid/relations/embedded/atomic/operation.rb', line 8 def documents @documents end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/mongoid/relations/embedded/atomic/operation.rb', line 8 def @options end |
#path ⇒ Object
Returns the value of attribute path.
8 9 10 |
# File 'lib/mongoid/relations/embedded/atomic/operation.rb', line 8 def path @path end |
#selector ⇒ Object
Returns the value of attribute selector.
8 9 10 |
# File 'lib/mongoid/relations/embedded/atomic/operation.rb', line 8 def selector @selector end |
Instance Method Details
#consume(selector, operations, options = {}) ⇒ Object
Consumes an execution that was supposed to hit the database, but is now being deferred to later in favor of a single update.
28 29 30 31 32 |
# File 'lib/mongoid/relations/embedded/atomic/operation.rb', line 28 def consume(selector, operations, = {}) @consumed, @selector, @options = true, selector, @documents ||= [] parse(operations) end |
#consumed? ⇒ true, false
Has this operation consumed any executions?
42 43 44 |
# File 'lib/mongoid/relations/embedded/atomic/operation.rb', line 42 def consumed? !!@consumed end |
#execute(collection) ⇒ Object
Execute the $pushAll operation on the collection.
54 55 56 57 58 |
# File 'lib/mongoid/relations/embedded/atomic/operation.rb', line 54 def execute(collection) if collection && consumed? collection.update(selector, operations, ) end end |