Class: Mongoid::Contextual::FindAndModify
- Inherits:
-
Object
- Object
- Mongoid::Contextual::FindAndModify
- Includes:
- Command
- Defined in:
- lib/mongoid/contextual/find_and_modify.rb
Instance Attribute Summary collapse
-
#criteria ⇒ Object
readonly
Returns the value of attribute criteria.
- #criteria The criteria for the context.(Thecriteria) ⇒ Object readonly
-
#options ⇒ Object
readonly
Returns the value of attribute options.
- #options The command options.(Thecommandoptions.) ⇒ Object readonly
-
#query ⇒ Object
readonly
Returns the value of attribute query.
- #query The Moped query.(TheMopedquery.) ⇒ Object readonly
-
#update ⇒ Object
readonly
Returns the value of attribute update.
- #update The updates.(Theupdates.) ⇒ Object readonly
Attributes included from Command
#collection, #collection The collection to query against.
Instance Method Summary collapse
-
#initialize(collection, criteria, update, options = {}) ⇒ FindAndModify
constructor
Initialize the find and modify command, used for MongoDB’s $findAndModify.
-
#result ⇒ Hash
Get the result of the $findAndModify.
Methods included from Command
Constructor Details
#initialize(collection, criteria, update, options = {}) ⇒ FindAndModify
Initialize the find and modify command, used for MongoDB’s $findAndModify.
28 29 30 31 32 33 |
# File 'lib/mongoid/contextual/find_and_modify.rb', line 28 def initialize(collection, criteria, update, = {}) @collection, @criteria, @options, @update = collection, criteria, , update.mongoize @query = collection.find(criteria.selector) end |
Instance Attribute Details
#criteria ⇒ Object (readonly)
Returns the value of attribute criteria.
11 12 13 |
# File 'lib/mongoid/contextual/find_and_modify.rb', line 11 def criteria @criteria end |
#criteria The criteria for the context.(Thecriteria) ⇒ Object (readonly)
11 |
# File 'lib/mongoid/contextual/find_and_modify.rb', line 11 attr_reader :criteria, :options, :update, :query |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/mongoid/contextual/find_and_modify.rb', line 11 def @options end |
#options The command options.(Thecommandoptions.) ⇒ Object (readonly)
11 |
# File 'lib/mongoid/contextual/find_and_modify.rb', line 11 attr_reader :criteria, :options, :update, :query |
#query ⇒ Object (readonly)
Returns the value of attribute query.
11 12 13 |
# File 'lib/mongoid/contextual/find_and_modify.rb', line 11 def query @query end |
#query The Moped query.(TheMopedquery.) ⇒ Object (readonly)
11 |
# File 'lib/mongoid/contextual/find_and_modify.rb', line 11 attr_reader :criteria, :options, :update, :query |
#update ⇒ Object (readonly)
Returns the value of attribute update.
11 12 13 |
# File 'lib/mongoid/contextual/find_and_modify.rb', line 11 def update @update end |
#update The updates.(Theupdates.) ⇒ Object (readonly)
11 |
# File 'lib/mongoid/contextual/find_and_modify.rb', line 11 attr_reader :criteria, :options, :update, :query |
Instance Method Details
#result ⇒ Hash
Get the result of the $findAndModify.
43 44 45 |
# File 'lib/mongoid/contextual/find_and_modify.rb', line 43 def result query.modify(update, ) end |