Class: ActiveRecord::Refined::AST::In
- Includes:
- SetSubquery
- 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
-
#negated ⇒ Object
readonly
Returns the value of attribute negated.
-
#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, negated: false) ⇒ In
constructor
A new instance of In.
- #to_arel(table, model) ⇒ Object
Methods inherited from Predicate
Methods inherited from Node
Constructor Details
#initialize(operand, values, negated: false) ⇒ In
Returns a new instance of In.
1213 1214 1215 1216 1217 |
# File 'lib/active_record/refined/ast.rb', line 1213 def initialize(operand, values, negated: false) @operand = operand @values = values @negated = negated end |
Instance Attribute Details
#negated ⇒ Object (readonly)
Returns the value of attribute negated.
1211 1212 1213 |
# File 'lib/active_record/refined/ast.rb', line 1211 def negated @negated end |
#operand ⇒ Object (readonly)
Returns the value of attribute operand.
1211 1212 1213 |
# File 'lib/active_record/refined/ast.rb', line 1211 def operand @operand end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
1211 1212 1213 |
# File 'lib/active_record/refined/ast.rb', line 1211 def values @values end |
Instance Method Details
#to_arel(table, model) ⇒ Object
1219 1220 1221 1222 1223 1224 1225 1226 1227 |
# File 'lib/active_record/refined/ast.rb', line 1219 def to_arel(table, model) arel_operand = to_arel_operand(operand, table, model) if values.is_a?(Range) arel_operand.public_send(negated ? :not_between : :between, values) else arg = values.is_a?(ActiveRecord::Relation) ? set_subquery(values, 'IN') : values arel_operand.public_send(negated ? :not_in : :in, arg) end end |