diff options
Diffstat (limited to 'lib/arel/algebra')
-rw-r--r-- | lib/arel/algebra/relations/writes.rb | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/lib/arel/algebra/relations/writes.rb b/lib/arel/algebra/relations/writes.rb index d344987915..17da2b172b 100644 --- a/lib/arel/algebra/relations/writes.rb +++ b/lib/arel/algebra/relations/writes.rb @@ -1,33 +1,35 @@ module Arel - class Deletion < Compound - attributes :relation - deriving :initialize, :== + 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 < Compound - attributes :relation, :record - deriving :== + class Insert < Action + attr_reader :record def initialize(relation, record) - @relation, @record = relation, record.bind(relation) + super(relation) + @record = 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) + def == other + super && @record == other.record end + end + + class Update < Insert + alias :assignments :record def call engine.update(self) |