aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/algebra/relations/writes.rb
blob: d344987915aa91661413b4ebd31646d9d3062734 (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
module Arel
  class Deletion < Compound
    attributes :relation
    deriving :initialize, :==

    def call
      engine.delete(self)
    end
  end

  class Insert < Compound
    attributes :relation, :record
    deriving :==

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

    def call
      engine.create(self)
    end
  end

  class Update < Compound
    attributes :relation, :assignments
    deriving :==

    def initialize(relation, assignments)
      @relation, @assignments = relation, assignments.bind(relation)
    end

    def call
      engine.update(self)
    end
  end
end