Class: DtkCommon::DynmamicLoader

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

Class Method Summary collapse

Class Method Details

.load_and_return_adapter_class(adapter_type, adapter_name, opts = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/dynamic_loader.rb', line 23

def self.load_and_return_adapter_class(adapter_type,adapter_name,opts={})
  begin
    caller_dir = caller.first.gsub(/\/[^\/]+$/,"")
    Lock.synchronize{nested_require_with_caller_dir(caller_dir,"#{adapter_type}/adapters",adapter_name)}
  rescue LoadError
    raise Error.new("cannot find #{adapter_type} adapter (#{adapter_name})")
  end
  base_class = opts[:base_class] || DtkCommon.const_get(camel_case(adapter_type))
  base_class.const_get(camel_case(adapter_name))
end