blob: d27d93a5dc8e5237f76e909b6512c36816486720 (
plain) (
tree)
|
|
module Arel
module Sql
class Engine
def initialize(ar = nil)
@ar = ar
end
def connection
@ar.connection
end
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)
# FIXME
rows = connection.select_rows(relation.to_sql)
class << rows
include Enumerable
end
Array.new(rows, relation.attributes)
end
def update(relation)
connection.update(relation.to_sql)
end
def delete(relation)
connection.delete(relation.to_sql)
end
end
include CRUD
end
end
end
|