Class: ActiveRecord::Refined::AST::In
- Defined in:
- lib/active_record/refined/ast.rb
Overview
IN for a list of values, BETWEEN for a range, IN (SELECT ...) for a relation.
Instance Attribute Summary collapse
-
#operand ⇒ Object
readonly
Returns the value of attribute operand.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
-
#initialize(operand, values) ⇒ In
constructor
A new instance of In.
- #to_arel(table) ⇒ Object
Methods inherited from Predicate
Methods inherited from Node
Constructor Details
#initialize(operand, values) ⇒ In
Returns a new instance of In.
242 243 244 245 |
# File 'lib/active_record/refined/ast.rb', line 242 def initialize(operand, values) @operand = operand @values = values end |
Instance Attribute Details
#operand ⇒ Object (readonly)
Returns the value of attribute operand.
240 241 242 |
# File 'lib/active_record/refined/ast.rb', line 240 def operand @operand end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
240 241 242 |
# File 'lib/active_record/refined/ast.rb', line 240 def values @values end |
Instance Method Details
#to_arel(table) ⇒ Object
247 248 249 250 251 252 253 254 |
# File 'lib/active_record/refined/ast.rb', line 247 def to_arel(table) arel_operand = to_arel_operand(operand, table) case values when Range then arel_operand.between(values) when ActiveRecord::Relation then arel_operand.in(subquery(values)) else arel_operand.in(values) end end |