Sha256: 8bbec35385e8f8ceaa211e690e8793d198ab4dae503e61c0a001e257be43cf9e
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
require 'sequel' module Enygma module Adapters class SequelAdapter < Enygma::Adapters::AbstractAdapter class InvalidTable < StandardError; end def connect!(datastore) @datastore = case datastore when Sequel::Model @table = datastore.table_name datastore.db when Sequel::Database datastore when :sqlite Sequel.sqlite else Sequel.connect(datastore) end end def query(args = {}) get_table(args[:table]).filter(:id => args[:ids]) end def get_attribute(record, attribute) record[attribute] end private def get_table(obj = nil) case obj when Symbol @datastore ? @datastore[obj] : raise(InvalidTable) when String @datastore ? @datastore[obj.to_sym] : raise(InvalidTable) when Sequel::Model obj when Sequel::Database @table ? obj[@table] : raise(InvalidTable) else raise InvalidTable end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sander6-enygma-0.1.0 | lib/enygma/adapters/sequel.rb |
sander6-enygma-0.1.1 | lib/enygma/adapters/sequel.rb |