Class: RRepo::Adapters::Mongo::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/rrepo/adapters/mongo.rb

Overview

A Mongo Query object

Instance Method Summary collapse

Constructor Details

#initialize(collection, &block) ⇒ Query

Returns a new instance of Query.



45
46
47
48
49
# File 'lib/rrepo/adapters/mongo.rb', line 45

def initialize(collection, &block)
  @collection = collection
  @query = {}
  instance_eval(&block) if block_given?
end

Instance Method Details

#runObject



55
56
57
# File 'lib/rrepo/adapters/mongo.rb', line 55

def run
  @collection.find(@query)
end

#to_hashObject



59
60
61
# File 'lib/rrepo/adapters/mongo.rb', line 59

def to_hash
  @query
end

#where(condition) ⇒ Object



51
52
53
# File 'lib/rrepo/adapters/mongo.rb', line 51

def where(condition)
  @query.merge!(condition)
end