Class: RRepo::Adapters::Mongo::Query
- Inherits:
-
Object
- Object
- RRepo::Adapters::Mongo::Query
- Defined in:
- lib/rrepo/adapters/mongo.rb
Overview
A Mongo Query object
Instance Method Summary collapse
-
#initialize(collection, &block) ⇒ Query
constructor
A new instance of Query.
- #run ⇒ Object
- #to_hash ⇒ Object
- #where(condition) ⇒ Object
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
#run ⇒ Object
55 56 57 |
# File 'lib/rrepo/adapters/mongo.rb', line 55 def run @collection.find(@query) end |
#to_hash ⇒ Object
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 |