Class: Imparcial::Initializer

Inherits:
Object
  • Object
show all
Defined in:
lib/imparcial/initializer.rb

Class Method Summary collapse

Class Method Details

.adapter(name) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/imparcial/initializer.rb', line 15

def self.adapter ( name )
      
  adapter = (get_adapter name).new

  yield adapter

  adapter
  
rescue LoadError
  
  raise AdapterNotFound.new(driver + ' cannot be found')
    
end

.get_adapter(name) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/imparcial/initializer.rb', line 5

def self.get_adapter ( name )
  
  name = name.to_s          
      
  require "imparcial/driver/#{name}"
            
  ("Imparcial::Driver::#{name.camelize}Adapter").to_const
   
end