aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/nodes/unary.rb
blob: 60cff1defe97a341a9dc8d225afca0444fb7a0db (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# frozen_string_literal: true
module Arel
  module Nodes
    class Unary < Arel::Nodes::Node
      attr_accessor :expr
      alias :value :expr

      def initialize expr
        super()
        @expr = expr
      end

      def hash
        @expr.hash
      end

      def eql? other
        self.class == other.class &&
          self.expr == other.expr
      end
      alias :== :eql?
    end

    %w{
      Bin
      Cube
      DistinctOn
      Group
      GroupingElement
      GroupingSet
      Lateral
      Limit
      Lock
      Not
      Offset
      On
      Ordering
      RollUp
      Top
    }.each do |name|
      const_set(name, Class.new(Unary))
    end
  end
end