aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/algebra/relations/writes.rb
blob: 17da2b172b8d707a5c3ce1079f3d366a94bf3b65 (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
module Arel
  class Action < Compound
    def == other
      super || self.class === other && @relation == other.relation
    end
  end

  class Deletion < Action
    def call
      engine.delete(self)
    end
  end

  class Insert < Action
    attr_reader :record

    def initialize(relation, record)
      super(relation)
      @record = record.bind(relation)
    end

    def call
      engine.create(self)
    end

    def == other
      super && @record == other.record
    end
  end

  class Update < Insert
    alias :assignments :record

    def call
      engine.update(self)
    end
  end
end