Class: Mongoose::Query
Instance Attribute Summary collapse
Instance Method Summary
collapse
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
#method_missing(name, *args) ⇒ Object
39
40
41
42
|
# File 'lib/mongoose/query.rb', line 39
def method_missing(name, *args)
@subquery_no += 1 if @subquery_type == :and
Property.new(name, self, @subquery_no, @subquery_type)
end
|
Instance Attribute Details
#predicates ⇒ Object
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
|