Sha256: 87c137fce55247fe836129467c5ee177c676636208a4dbf2733cc1dcb6db90da

Contents?: true

Size: 703 Bytes

Versions: 8

Compression:

Stored size: 703 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

8 entries across 8 versions & 4 rubygems

Version Path
mongoid-1.9.5 lib/mongoid/contexts.rb
mongoid-with-auth-1.9.4 lib/mongoid/contexts.rb
mongoid-rails2-1.9.4 lib/mongoid/contexts.rb
mongoid-rails2-1.9.3 lib/mongoid/contexts.rb
mongoid-1.9.2 lib/mongoid/contexts.rb
sskirby-mongoid-1.9.1 lib/mongoid/contexts.rb
mongoid-1.9.1 lib/mongoid/contexts.rb
mongoid-1.9.0 lib/mongoid/contexts.rb