module Mongoid::Contextual::Command
Attributes
collection[R]
@attribute [r] collection The collection to query against. @attribute [r] criteria The criteria for the context.
criteria[R]
@attribute [r] collection The collection to query against. @attribute [r] criteria The criteria for the context.
Public Instance Methods
command()
click to toggle source
The database command that is being built to send to the db.
@example Get the command.
command.command
@return [ Hash ] The db command.
@since 3.0.0
# File lib/mongoid/contextual/command.rb, line 18 def command @command ||= {} end
session()
click to toggle source
Get the database session.
@example Get the session.
command.session
@return [ Session ] The Moped
session.
@since 3.0.0
# File lib/mongoid/contextual/command.rb, line 30 def session collection.database.session end
Private Instance Methods
selecting(param) { || ... }
click to toggle source
Execute the block setting field limitations.
@api private
@example Execute with field limitations.
text_search.selecting do #... end
@param [ Symbol
] param The name of the command parameter.
@return [ Object
] The result of the yield.
@since 4.0.0
# File lib/mongoid/contextual/command.rb, line 50 def selecting(param) begin fields = command[param] Threaded.set_selection(criteria.object_id, fields) unless fields.blank? yield ensure Threaded.delete_selection(criteria.object_id) end end