Sha256: 46cc7eeae92934e8bcad618d14053ca56cdd464ff6428be42ce0e6a0843724f4
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
module ActiveAdapter class Engine class << self def adapters @adapters ||= {} end def adapt(adapter) adapters[adapter.to_s] ||= begin module_name = "#{name.deconstantize}::#{name.demodulize}Adapters" abstract_adapter_class = get_abstract_adapter_class(module_name) implement_adapter_class = get_implement_adapter_class(module_name, adapter) implement_adapter_class.abstract_adapter = abstract_adapter_class abstract_adapter_class.new(implement_adapter_class) end end private def get_implement_adapter_class(module_name, adapter) "#{module_name}::#{adapter.to_s.camelize}".constantize rescue NameError => e raise ActiveAdapter::ImplementAdapterUndefinedError, e end def get_abstract_adapter_class(module_name) "#{module_name}::Abstract".constantize rescue NameError => e raise ActiveAdapter::AbstractAdapterUndefinedError, e end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_adapter-0.1.0.pre | lib/active_adapter/engine.rb |