Sha256: 58303a64b80d134c4294e2e612e7d324e2971b43c247c88541b30c52dc9b450a

Contents?: true

Size: 623 Bytes

Versions: 3

Compression:

Stored size: 623 Bytes

Contents

# encoding: utf-8
require "mongoid/contexts/paging"
require "mongoid/contexts/enumerable"
require "mongoid/contexts/mongo"

module Mongoid
  module Contexts
    # 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:
    #
    # <tt>Contexts.context_for(criteria)</tt>
    def self.context_for(criteria, embedded = false)
      embedded ? Enumerable.new(criteria) : Mongo.new(criteria)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongoid-2.0.1 lib/mongoid/contexts.rb
mongoid-2.0.0 lib/mongoid/contexts.rb
mongoid-2.0.0.rc.8 lib/mongoid/contexts.rb