Class: Perpetuity::MongoDB::QueryExpression
- Inherits:
-
Object
- Object
- Perpetuity::MongoDB::QueryExpression
- Defined in:
- lib/perpetuity/mongodb/query_expression.rb
Instance Attribute Summary collapse
-
#comparator ⇒ Object
Returns the value of attribute comparator.
Instance Method Summary collapse
- #&(other) ⇒ Object
- #equals ⇒ Object
- #function(func) ⇒ Object
- #greater_than ⇒ Object
- #gte ⇒ Object
- #in ⇒ Object
-
#initialize(attribute, comparator, value) ⇒ QueryExpression
constructor
A new instance of QueryExpression.
- #less_than ⇒ Object
- #lte ⇒ Object
- #matches ⇒ Object
- #not_equal ⇒ Object
- #to_db ⇒ Object
- #|(other) ⇒ Object
Constructor Details
#initialize(attribute, comparator, value) ⇒ QueryExpression
Returns a new instance of QueryExpression.
9 10 11 12 13 14 15 |
# File 'lib/perpetuity/mongodb/query_expression.rb', line 9 def initialize attribute, comparator, value @attribute = attribute @comparator = comparator @value = value @attribute = @attribute.to_sym if @attribute.respond_to? :to_sym end |
Instance Attribute Details
#comparator ⇒ Object
Returns the value of attribute comparator.
7 8 9 |
# File 'lib/perpetuity/mongodb/query_expression.rb', line 7 def comparator @comparator end |
Instance Method Details
#&(other) ⇒ Object
61 62 63 |
# File 'lib/perpetuity/mongodb/query_expression.rb', line 61 def & other QueryIntersection.new(self, other) end |
#equals ⇒ Object
21 22 23 |
# File 'lib/perpetuity/mongodb/query_expression.rb', line 21 def equals { @attribute => @value } end |
#function(func) ⇒ Object
25 26 27 |
# File 'lib/perpetuity/mongodb/query_expression.rb', line 25 def function func { @attribute => { func => @value } } end |
#greater_than ⇒ Object
37 38 39 |
# File 'lib/perpetuity/mongodb/query_expression.rb', line 37 def greater_than function '$gt' end |
#gte ⇒ Object
41 42 43 |
# File 'lib/perpetuity/mongodb/query_expression.rb', line 41 def gte function '$gte' end |
#in ⇒ Object
49 50 51 |
# File 'lib/perpetuity/mongodb/query_expression.rb', line 49 def in function '$in' end |
#less_than ⇒ Object
29 30 31 |
# File 'lib/perpetuity/mongodb/query_expression.rb', line 29 def less_than function '$lt' end |
#lte ⇒ Object
33 34 35 |
# File 'lib/perpetuity/mongodb/query_expression.rb', line 33 def lte function '$lte' end |
#matches ⇒ Object
53 54 55 |
# File 'lib/perpetuity/mongodb/query_expression.rb', line 53 def matches { @attribute => @value } end |
#not_equal ⇒ Object
45 46 47 |
# File 'lib/perpetuity/mongodb/query_expression.rb', line 45 def not_equal function '$ne' end |
#to_db ⇒ Object
17 18 19 |
# File 'lib/perpetuity/mongodb/query_expression.rb', line 17 def to_db send @comparator end |
#|(other) ⇒ Object
57 58 59 |
# File 'lib/perpetuity/mongodb/query_expression.rb', line 57 def | other QueryUnion.new(self, other) end |