Class: Arel::Predicates::Binary
- Defined in:
- lib/arel/algebra/predicates.rb
Direct Known Subclasses
CompoundPredicate, Equality, GreaterThan, GreaterThanOrEqualTo, In, LessThan, LessThanOrEqualTo, Match, NotIn, NotMatch
Instance Attribute Summary collapse
-
#operand2 ⇒ Object
readonly
Returns the value of attribute operand2.
Attributes inherited from Unary
Instance Method Summary collapse
- #==(other) ⇒ Object
- #bind(relation) ⇒ Object
- #eval(row) ⇒ Object
-
#initialize(left, right) ⇒ Binary
constructor
A new instance of Binary.
- #to_sql(formatter = nil) ⇒ Object (also: #value)
Methods inherited from Predicate
#and, #complement, #not, #or
Constructor Details
#initialize(left, right) ⇒ Binary
Returns a new instance of Binary.
124 125 126 127 |
# File 'lib/arel/algebra/predicates.rb', line 124 def initialize left, right super(left) @operand2 = right end |
Instance Attribute Details
#operand2 ⇒ Object (readonly)
Returns the value of attribute operand2.
121 122 123 |
# File 'lib/arel/algebra/predicates.rb', line 121 def operand2 @operand2 end |
Instance Method Details
#==(other) ⇒ Object
129 130 131 |
# File 'lib/arel/algebra/predicates.rb', line 129 def ==(other) super && @operand2 == other.operand2 end |
#bind(relation) ⇒ Object
133 134 135 |
# File 'lib/arel/algebra/predicates.rb', line 133 def bind(relation) self.class.new(operand1.find_correlate_in(relation), operand2.find_correlate_in(relation)) end |
#eval(row) ⇒ Object
137 138 139 |
# File 'lib/arel/algebra/predicates.rb', line 137 def eval(row) operand1.eval(row).send(operator, operand2.eval(row)) end |
#to_sql(formatter = nil) ⇒ Object Also known as: value
141 142 143 |
# File 'lib/arel/algebra/predicates.rb', line 141 def to_sql(formatter = nil) "#{operand1.to_sql} #{predicate_sql} #{operand1.format(operand2)}" end |