Class: Enygma::Adapters::ActiveRecordAdapter

Inherits:
AbstractAdapter show all
Defined in:
lib/enygma/adapters/active_record.rb

Instance Attribute Summary

Attributes inherited from AbstractAdapter

#datastore

Instance Method Summary collapse

Instance Method Details

#connect!(datastore) ⇒ Object



9
10
11
12
13
14
# File 'lib/enygma/adapters/active_record.rb', line 9

def connect!(datastore)
  unless datastore.is_a?(Class) && datastore.ancestors.include?(ActiveRecord::Base)
    raise InvalidDatabase, "#{datastore.inspect} is not an ActiveRecord::Base subclass!"
  end
  @datastore = datastore
end

#get_attribute(record, attribute) ⇒ Object



20
21
22
# File 'lib/enygma/adapters/active_record.rb', line 20

def get_attribute(record, attribute)
  record.read_attribute(attribute)
end

#query(args = {}) ⇒ Object



16
17
18
# File 'lib/enygma/adapters/active_record.rb', line 16

def query(args = {})
  @datastore.scoped(:conditions => { :id => args[:ids] })
end