Class: Arel::Predicates::In

Inherits:
Binary show all
Defined in:
lib/arel/algebra/predicates.rb,
lib/arel/engines/sql/predicates.rb,
lib/arel/engines/memory/predicates.rb

Instance Method Summary collapse

Methods inherited from Binary

#==, #bind

Methods inherited from Predicate

#and, #not, #or

Instance Method Details

#complementObject



179
180
181
# File 'lib/arel/algebra/predicates.rb', line 179

def complement
  NotIn.new(operand1, operand2)
end

#eval(row) ⇒ Object



88
89
90
# File 'lib/arel/engines/memory/predicates.rb', line 88

def eval(row)
  operand2.eval(row).include?(operand1.eval(row))
end

#predicate_sqlObject



96
# File 'lib/arel/engines/sql/predicates.rb', line 96

def predicate_sql; operand2.inclusion_predicate_sql end

#to_sql(formatter = nil) ⇒ Object



86
87
88
89
90
91
92
93
94
# File 'lib/arel/engines/sql/predicates.rb', line 86

def to_sql(formatter = nil)
  if operand2.is_a?(Range) && operand2.exclude_end?
    GreaterThanOrEqualTo.new(operand1, operand2.begin).and(
      LessThan.new(operand1, operand2.end)
    ).to_sql(formatter)
  else
    super
  end
end