class Rebels::RailsAdapters::Database
Public Class Methods
new(tables)
click to toggle source
# File lib/rebels/rails_adapters/database.rb, line 2 def initialize(tables) @tables = tables end
Public Instance Methods
insert(table, record)
click to toggle source
# File lib/rebels/rails_adapters/database.rb, line 5 def insert(table, record) @tables[table].first.create!(record.attributes) end
update(table, id, attrs)
click to toggle source
# File lib/rebels/rails_adapters/database.rb, line 15 def update(table, id, attrs) @tables[table].first.find(id).update_attributes(attrs) end
where(table, filters)
click to toggle source
# File lib/rebels/rails_adapters/database.rb, line 8 def where(table, filters) @tables[table].first.where(filters).map do |ar| keys = @tables[table].last.with({}).attributes.keys attrs = keys.reduce({}){|m,e| m.merge(e => ar.attributes[e.to_s])} @tables[table].last.with(attrs) end end