Class: Arel::Predicates::Binary

Inherits:
Unary show all
Defined in:
lib/arel/algebra/predicates.rb

Instance Attribute Summary collapse

Attributes inherited from Unary

#operand

Instance Method Summary collapse

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

#operand2Object (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