aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/algebra/relations/writes.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel/algebra/relations/writes.rb')
-rw-r--r--lib/arel/algebra/relations/writes.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/arel/algebra/relations/writes.rb b/lib/arel/algebra/relations/writes.rb
new file mode 100644
index 0000000000..d344987915
--- /dev/null
+++ b/lib/arel/algebra/relations/writes.rb
@@ -0,0 +1,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