aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/arel/nodes/extract.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/arel/nodes/extract.rb')
-rw-r--r--activerecord/lib/arel/nodes/extract.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/activerecord/lib/arel/nodes/extract.rb b/activerecord/lib/arel/nodes/extract.rb
new file mode 100644
index 0000000000..5799ee9b8f
--- /dev/null
+++ b/activerecord/lib/arel/nodes/extract.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+module Arel # :nodoc: all
+ module Nodes
+ class Extract < Arel::Nodes::Unary
+ attr_accessor :field
+
+ def initialize(expr, field)
+ super(expr)
+ @field = field
+ end
+
+ def hash
+ super ^ @field.hash
+ end
+
+ def eql?(other)
+ super &&
+ self.field == other.field
+ end
+ alias :== :eql?
+ end
+ end
+end