Class: ActiveRecord::Refined::AST::In

Inherits:
Predicate show all
Defined in:
lib/active_record/refined/ast.rb

Overview

IN for a list of values, BETWEEN for a range.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Predicate

#!, #&, #|

Methods inherited from Node

#as, #asc, #desc

Constructor Details

#initialize(operand, values) ⇒ In

Returns a new instance of In.



222
223
224
225
# File 'lib/active_record/refined/ast.rb', line 222

def initialize(operand, values)
  @operand = operand
  @values = values
end

Instance Attribute Details

#operandObject (readonly)

Returns the value of attribute operand.



220
221
222
# File 'lib/active_record/refined/ast.rb', line 220

def operand
  @operand
end

#valuesObject (readonly)

Returns the value of attribute values.



220
221
222
# File 'lib/active_record/refined/ast.rb', line 220

def values
  @values
end

Instance Method Details

#to_arel(table) ⇒ Object



227
228
229
230
231
232
233
# File 'lib/active_record/refined/ast.rb', line 227

def to_arel(table)
  arel_operand = to_arel_operand(operand, table)
  case values
  when Range then arel_operand.between(values)
  else arel_operand.in(values)
  end
end