Sha256: 3fdd7c48f13945838c4056ddd126ff788fd8fc077c35d953a4b9d90f3f7b103b

Contents?: true

Size: 616 Bytes

Versions: 1

Compression:

Stored size: 616 Bytes

Contents

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-0.7.6 lib/mongo_mapper/query.rb