Class: Dynomite::Item::Query::Relation::ComparisionExpression

Inherits:
Object
  • Object
show all
Defined in:
lib/dynomite/item/query/relation/comparision_expression.rb

Instance Method Summary collapse

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

#buildObject



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

Returns:

  • (Boolean)


7
8
9
# File 'lib/dynomite/item/query/relation/comparision_expression.rb', line 7

def or?
  @where_group.or?
end