Class: Mongoose::Query
Instance Attribute Summary collapse
-
#predicates ⇒ Object
readonly
Returns the value of attribute predicates.
Instance Method Summary collapse
- #add_predicate(pred) ⇒ Object
- #any(&block) ⇒ Object
- #find {|_self| ... } ⇒ Object
-
#initialize ⇒ Query
constructor
A new instance of Query.
- #method_missing(name, *args) ⇒ Object
Constructor Details
#initialize ⇒ Query
Returns a new instance of Query.
25 26 27 28 29 |
# File 'lib/mongoose/query.rb', line 25 def initialize @predicates = [] @subquery_type = :and @subquery_no = 0 end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
Instance Attribute Details
#predicates ⇒ Object (readonly)
Returns the value of attribute predicates.
24 25 26 |
# File 'lib/mongoose/query.rb', line 24 def predicates @predicates end |
Instance Method Details
#add_predicate(pred) ⇒ Object
35 36 37 |
# File 'lib/mongoose/query.rb', line 35 def add_predicate(pred) @predicates << pred end |
#any(&block) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/mongoose/query.rb', line 44 def any(&block) @subquery_type = :or @subquery_no += 1 yield @subquery_type = :and end |
#find {|_self| ... } ⇒ Object
31 32 33 |
# File 'lib/mongoose/query.rb', line 31 def find(&block) yield self end |