Methods

Class/Module Index [+]

Quicksearch

Mongoid::Contexts

Public Instance Methods

context_for(criteria, embedded = false) click to toggle source

Determines the context to be used for this criteria. If the class is an embedded document, then the context will be the array in the has_many association it is in. If the class is a root, then the database itself will be the context.

@example Get the context for the criteria.

Contexts.context_for(criteria)

@param [ Criteria ] criteria The criteria to use. @param [ true, false ] embedded Whether this is on embedded documents.

@return [ Enumerable, Mongo ] The appropriate context.

# File lib/mongoid/contexts.rb, line 20
def context_for(criteria, embedded = false)
  embedded ? Enumerable.new(criteria) : Mongo.new(criteria)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.