Class: ActiveRecord::Refined::AST::DistinctFrom
- Defined in:
- lib/active_record/refined/ast.rb
Overview
IS [NOT] DISTINCT FROM, spelled IS / IS NOT on SQLite and <=> on MySQL. NULL compares as a value here, which is what separates these from = and <>.
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) ⇒ DistinctFrom
constructor
A new instance of DistinctFrom.
- #to_arel(table, model) ⇒ Object
Methods inherited from Predicate
Methods inherited from Node
Constructor Details
#initialize(operand, value, negated: false) ⇒ DistinctFrom
Returns a new instance of DistinctFrom.
2048 2049 2050 2051 2052 |
# File 'lib/active_record/refined/ast.rb', line 2048 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.
2046 2047 2048 |
# File 'lib/active_record/refined/ast.rb', line 2046 def negated @negated end |
#operand ⇒ Object (readonly)
Returns the value of attribute operand.
2046 2047 2048 |
# File 'lib/active_record/refined/ast.rb', line 2046 def operand @operand end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
2046 2047 2048 |
# File 'lib/active_record/refined/ast.rb', line 2046 def value @value end |
Instance Method Details
#to_arel(table, model) ⇒ Object
2054 2055 2056 2057 2058 2059 2060 2061 2062 |
# File 'lib/active_record/refined/ast.rb', line 2054 def to_arel(table, model) arel_operand = to_arel_operand(operand, table, model) arel_value = value.is_a?(Node) ? value.to_arel(table, model) : value if negated arel_operand.is_distinct_from(arel_value) else arel_operand.is_not_distinct_from(arel_value) end end |