Sha256: 3f7c17b391ee69079f65d86cc3b7d2f99a7fb42c9385d126a20ea1b5056b7bff

Contents?: true

Size: 702 Bytes

Versions: 10

Compression:

Stored size: 702 Bytes

Contents

# encoding: utf-8
require "mongoid/contexts/ids"
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)
      if criteria.klass.embedded
        return Contexts::Enumerable.new(criteria)
      end
      Contexts::Mongo.new(criteria)
    end

  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
mongoid-pre-2.0.0.beta1 lib/mongoid/contexts.rb
mongoid-2.0.0.alpha lib/mongoid/contexts.rb
mongoid-1.2.14 lib/mongoid/contexts.rb
mongoid-1.2.13 lib/mongoid/contexts.rb
mongoid-1.2.12 lib/mongoid/contexts.rb
mongoid-1.2.11 lib/mongoid/contexts.rb
mongoid-1.2.10 lib/mongoid/contexts.rb
mongoid-1.2.9 lib/mongoid/contexts.rb
mongoid-1.2.8 lib/mongoid/contexts.rb
mongoid-1.2.7 lib/mongoid/contexts.rb