Sha256: 0e43341dbf00d142d8ad57eaa66e914d13a4825dbb8746e8dc5cff40a86bf76b

Contents?: true

Size: 634 Bytes

Versions: 1

Compression:

Stored size: 634 Bytes

Contents

# encoding: UTF-8
module MongoMapper
  class Query
    def initialize(model, options={})
      raise ArgumentError, "Options must be a hash" unless options.is_a?(Hash)
      @model, @options, @conditions = model, {}, {}
      query.update(options)
      add_sci_condition
    end

    private
      def method_missing(method, *args, &block)
        query.send(method, *args, &block)
      end

      def query
        @query ||= Plucky::Query.new(@model.collection).object_ids(@model.object_id_keys)
      end

      def add_sci_condition
        query[:_type] = @model.to_s if @model.single_collection_inherited?
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongo_mapper_ign-0.7.6 lib/mongo_mapper/query.rb