1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/lib/arel/nodes/binary.rb

61 lines
1.1 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2018-02-24 01:45:50 -05:00
2018-02-24 02:41:47 -05:00
module Arel # :nodoc: all
2010-08-16 20:26:12 -04:00
module Nodes
class Binary < Arel::Nodes::NodeExpression
2010-08-16 20:26:12 -04:00
attr_accessor :left, :right
2018-02-24 01:45:50 -05:00
def initialize(left, right)
2013-05-17 18:43:54 -04:00
super()
2010-08-16 20:26:12 -04:00
@left = left
@right = right
end
2010-12-14 23:31:49 -05:00
def detect_attribute
if self.left.is_a?(Arel::Attributes::Attribute)
self.left
elsif self.right.is_a?(Arel::Attributes::Attribute)
self.right
end
end
2018-02-24 01:45:50 -05:00
def initialize_copy(other)
2010-12-14 23:31:49 -05:00
super
@left = @left.clone if @left
@right = @right.clone if @right
end
def hash
[self.class, @left, @right].hash
end
2018-02-24 01:45:50 -05:00
def eql?(other)
self.class == other.class &&
self.left == other.left &&
self.right == other.right
end
alias :== :eql?
2010-08-16 20:26:12 -04:00
end
2010-12-14 21:13:06 -05:00
%w{
As
2010-12-15 00:06:16 -05:00
Assignment
Between
2010-12-14 21:13:06 -05:00
GreaterThan
GreaterThanOrEqual
2010-12-15 00:06:16 -05:00
Join
2010-12-14 21:13:06 -05:00
LessThan
LessThanOrEqual
2010-12-15 00:06:16 -05:00
NotEqual
2010-12-14 23:31:49 -05:00
NotIn
2010-12-15 00:06:16 -05:00
Or
Union
UnionAll
2011-01-22 09:16:53 -05:00
Intersect
Except
2010-12-14 21:13:06 -05:00
}.each do |name|
2010-12-15 00:06:16 -05:00
const_set name, Class.new(Binary)
2010-12-14 21:13:06 -05:00
end
2010-08-16 20:26:12 -04:00
end
end