aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/engine.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel/engine.rb')
-rw-r--r--lib/arel/engine.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/arel/engine.rb b/lib/arel/engine.rb
index 5a5ef06878..2bb4bbbd90 100644
--- a/lib/arel/engine.rb
+++ b/lib/arel/engine.rb
@@ -14,5 +14,29 @@ module Arel
def method_missing(method, *args, &block)
@ar.connection.send(method, *args, &block)
end
+
+ module CRUD
+ def create(relation)
+ connection.insert(relation.to_sql)
+ end
+
+ def read(relation)
+ results = connection.execute(relation.to_sql)
+ rows = []
+ results.each do |row|
+ rows << attributes.zip(row).to_hash
+ end
+ rows
+ end
+
+ def update(relation)
+ connection.update(relation.to_sql)
+ end
+
+ def delete(relation)
+ connection.delete(relation.to_sql)
+ end
+ end
+ include CRUD
end
end