2012-02-23 08:06:05 -05:00
|
|
|
module Arel
|
|
|
|
module Nodes
|
|
|
|
class Extract < Arel::Nodes::Unary
|
2014-09-13 22:35:34 -04:00
|
|
|
include Arel::AliasPredication
|
2012-02-23 08:06:05 -05:00
|
|
|
include Arel::Predications
|
|
|
|
|
|
|
|
attr_accessor :field
|
|
|
|
|
2014-09-13 22:35:34 -04:00
|
|
|
def initialize expr, field
|
2012-02-23 08:06:05 -05:00
|
|
|
super(expr)
|
|
|
|
@field = field
|
|
|
|
end
|
2012-08-18 22:33:25 -04:00
|
|
|
|
|
|
|
def hash
|
2014-09-16 11:12:56 -04:00
|
|
|
super ^ @field.hash
|
2012-08-18 22:33:25 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def eql? other
|
|
|
|
super &&
|
2014-09-13 22:35:34 -04:00
|
|
|
self.field == other.field
|
2012-08-18 22:33:25 -04:00
|
|
|
end
|
|
|
|
alias :== :eql?
|
2012-02-23 08:06:05 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|