Class: Dynomite::Item::Query::Relation::ComparisionExpression
- Inherits:
-
Object
- Object
- Dynomite::Item::Query::Relation::ComparisionExpression
- Defined in:
- lib/dynomite/item/query/relation/comparision_expression.rb
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(where_group, comparisions) ⇒ ComparisionExpression
constructor
A new instance of ComparisionExpression.
- #or? ⇒ Boolean
Constructor Details
#initialize(where_group, comparisions) ⇒ ComparisionExpression
Returns a new instance of ComparisionExpression.
3 4 5 |
# File 'lib/dynomite/item/query/relation/comparision_expression.rb', line 3 def initialize(where_group, comparisions) @where_group, @comparisions = where_group, comparisions end |
Instance Method Details
#build ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/dynomite/item/query/relation/comparision_expression.rb', line 11 def build # join @comparisions with AND if there are more than one expression = [] expression << 'NOT' if @where_group.not? expression << '(' if @comparisions.size > 1 expression << @comparisions.join(' AND ') # always AND within a group expression << ')' if @comparisions.size > 1 expression.join(' ') end |
#or? ⇒ Boolean
7 8 9 |
# File 'lib/dynomite/item/query/relation/comparision_expression.rb', line 7 def or? @where_group.or? end |