Module: Mongoid::Contextual

Extended by:
Forwardable
Included in:
Criteria
Defined in:
build/mongoid-master/lib/mongoid/contextual.rb,
build/mongoid-master/lib/mongoid/contextual/none.rb,
build/mongoid-master/lib/mongoid/contextual/mongo.rb,
build/mongoid-master/lib/mongoid/contextual/atomic.rb,
build/mongoid-master/lib/mongoid/contextual/memory.rb,
build/mongoid-master/lib/mongoid/contextual/command.rb,
build/mongoid-master/lib/mongoid/contextual/geo_near.rb,
build/mongoid-master/lib/mongoid/contextual/queryable.rb,
build/mongoid-master/lib/mongoid/contextual/aggregable.rb,
build/mongoid-master/lib/mongoid/contextual/map_reduce.rb,
build/mongoid-master/lib/mongoid/contextual/aggregable/none.rb,
build/mongoid-master/lib/mongoid/contextual/aggregable/mongo.rb,
build/mongoid-master/lib/mongoid/contextual/aggregable/memory.rb,
build/mongoid-master/lib/mongoid/contextual/mongo/documents_loader.rb

Defined Under Namespace

Modules: Aggregable, Atomic, Command, Queryable Classes: GeoNear, MapReduce, Memory, Mongo, None

Instance Method Summary collapse

Instance Method Details

#contextMemory | Mongo

Get the context in which criteria queries should execute. This is either in memory (for embedded documents) or mongo (for root level documents.)

Examples:

Get the context.

criteria.context

Returns:



34
35
36
# File 'build/mongoid-master/lib/mongoid/contextual.rb', line 34

def context
  @context ||= create_context
end

#load_asyncCriteria

Instructs the context to schedule an asynchronous loading of documents specified by the criteria.

Note that depending on the context and on the Mongoid configuration, documents can be loaded synchronously on the caller’s thread.

Returns:



45
46
47
48
# File 'build/mongoid-master/lib/mongoid/contextual.rb', line 45

def load_async
  context.load_async if context.respond_to?(:load_async)
  self
end