Class: Daodalus::DSL::Query
- Inherits:
-
Object
- Object
- Daodalus::DSL::Query
- Defined in:
- lib/daodalus/dsl/query.rb
Instance Attribute Summary collapse
-
#updates ⇒ Object
readonly
Returns the value of attribute updates.
-
#wheres ⇒ Object
readonly
Returns the value of attribute wheres.
Instance Method Summary collapse
- #has_selects? ⇒ Boolean
-
#initialize(wheres = {}, selects = {}, updates = {}) ⇒ Query
constructor
A new instance of Query.
- #select(clause) ⇒ Object
- #selects ⇒ Object
- #update(clause) ⇒ Object
- #where(clause) ⇒ Object
Constructor Details
#initialize(wheres = {}, selects = {}, updates = {}) ⇒ Query
Returns a new instance of Query.
5 6 7 8 9 |
# File 'lib/daodalus/dsl/query.rb', line 5 def initialize(wheres={}, selects={}, updates={}) @wheres = wheres @selects = selects @updates = updates end |
Instance Attribute Details
#updates ⇒ Object (readonly)
Returns the value of attribute updates.
10 11 12 |
# File 'lib/daodalus/dsl/query.rb', line 10 def updates @updates end |
#wheres ⇒ Object (readonly)
Returns the value of attribute wheres.
10 11 12 |
# File 'lib/daodalus/dsl/query.rb', line 10 def wheres @wheres end |
Instance Method Details
#has_selects? ⇒ Boolean
28 29 30 |
# File 'lib/daodalus/dsl/query.rb', line 28 def has_selects? !selects.empty? end |
#select(clause) ⇒ Object
20 21 22 |
# File 'lib/daodalus/dsl/query.rb', line 20 def select clause Query.new(wheres, selects.merge(clause), updates) end |
#selects ⇒ Object
24 25 26 |
# File 'lib/daodalus/dsl/query.rb', line 24 def selects @selects.empty? ? @selects : {'_id' => 0}.merge(@selects) end |