delete_statement.rb 1.1 KB
Newer Older
1
# frozen_string_literal: true
M
Matthew Draper 已提交
2

M
Matthew Draper 已提交
3
module Arel # :nodoc: all
A
Aaron Patterson 已提交
4
  module Nodes
5
    class DeleteStatement < Arel::Nodes::Node
6
      attr_accessor :left, :right, :orders, :limit, :offset, :key
B
Bradford Folkens 已提交
7

8 9 10 11
      alias :relation :left
      alias :relation= :left=
      alias :wheres :right
      alias :wheres= :right=
A
Aaron Patterson 已提交
12

M
Matthew Draper 已提交
13
      def initialize(relation = nil, wheres = [])
14 15 16
        super()
        @left = relation
        @right = wheres
17 18
        @orders = []
        @limit = nil
19
        @offset = nil
20
        @key = nil
A
Aaron Patterson 已提交
21
      end
M
Mike Dalessio 已提交
22

M
Matthew Draper 已提交
23
      def initialize_copy(other)
M
Mike Dalessio 已提交
24
        super
25 26 27 28 29
        @left  = @left.clone if @left
        @right = @right.clone if @right
      end

      def hash
30
        [self.class, @left, @right, @orders, @limit, @offset, @key].hash
31 32
      end

M
Matthew Draper 已提交
33
      def eql?(other)
34 35
        self.class == other.class &&
          self.left == other.left &&
36 37 38
          self.right == other.right &&
          self.orders == other.orders &&
          self.limit == other.limit &&
39
          self.offset == other.offset &&
40
          self.key == other.key
M
Mike Dalessio 已提交
41
      end
42
      alias :== :eql?
A
Aaron Patterson 已提交
43 44 45
    end
  end
end