Class: ActiveRecord::Refined::AST::TruthValue
- Defined in:
- lib/active_record/refined/ast.rb
Overview
IS TRUE, IS FALSE and their negations, which every adapter spells the same way and answers alike, NULL included.
Instance Attribute Summary collapse
-
#negated ⇒ Object
readonly
Returns the value of attribute negated.
-
#operand ⇒ Object
readonly
Returns the value of attribute operand.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(operand, value, negated: false) ⇒ TruthValue
constructor
A new instance of TruthValue.
- #to_arel(table, model) ⇒ Object
Methods inherited from Predicate
Methods inherited from Node
Constructor Details
#initialize(operand, value, negated: false) ⇒ TruthValue
Returns a new instance of TruthValue.
1172 1173 1174 1175 1176 |
# File 'lib/active_record/refined/ast.rb', line 1172 def initialize(operand, value, negated: false) @operand = operand @value = value @negated = negated end |
Instance Attribute Details
#negated ⇒ Object (readonly)
Returns the value of attribute negated.
1170 1171 1172 |
# File 'lib/active_record/refined/ast.rb', line 1170 def negated @negated end |
#operand ⇒ Object (readonly)
Returns the value of attribute operand.
1170 1171 1172 |
# File 'lib/active_record/refined/ast.rb', line 1170 def operand @operand end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
1170 1171 1172 |
# File 'lib/active_record/refined/ast.rb', line 1170 def value @value end |
Instance Method Details
#to_arel(table, model) ⇒ Object
1178 1179 1180 1181 1182 |
# File 'lib/active_record/refined/ast.rb', line 1178 def to_arel(table, model) literal = value ? Arel::Nodes::True.new : Arel::Nodes::False.new Arel::Nodes::InfixOperation.new(negated ? 'IS NOT' : 'IS', to_arel_operand(operand, table, model), literal) end |