Sha256: c204a8792db1dcd20910498cbed2c8b8eb8d91780c7a431507a6123b4ab66006

Contents?: true

Size: 716 Bytes

Versions: 1

Compression:

Stored size: 716 Bytes

Contents

# encoding: utf-8
require "mongoid/contexts/paging"
require "mongodoc/contexts/enumerable"
require "mongodoc/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.respond_to?(:collection)
        return MongoDoc::Contexts::Mongo.new(criteria)
      end
      return MongoDoc::Contexts::Enumerable.new(criteria)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongodoc-0.2.4 lib/mongodoc/contexts.rb