Class: Sow::Adapter

Inherits:
Object
  • Object
show all
Defined in:
lib/seed_drill/adapter.rb

Direct Known Subclasses

ActiveRecord

Class Method Summary collapse

Class Method Details

.adaptersObject


10
11
12
# File 'lib/seed_drill/adapter.rb', line 10

def self.adapters
  Hash[descendants.map{|klass| [klass.target_name, klass] }]
end

.get(klass) ⇒ Object


3
4
5
6
7
8
# File 'lib/seed_drill/adapter.rb', line 3

def self.get(klass)
  relation = klass.where(nil)
  key = (targets & relation.ancestors.map(&:to_s)).first
  adapter = adapters[key]
  adapter.new(relation)
end