Class: Nab::AdapterManager
- Inherits:
-
Object
- Object
- Nab::AdapterManager
- Defined in:
- lib/nab/adapter_manager.rb
Instance Attribute Summary collapse
-
#strip_dirs ⇒ Object
Returns the value of attribute strip_dirs.
-
#write_adapter ⇒ Object
Returns the value of attribute write_adapter.
Instance Method Summary collapse
- #get(type) ⇒ Object
-
#initialize ⇒ AdapterManager
constructor
A new instance of AdapterManager.
Constructor Details
#initialize ⇒ AdapterManager
Returns a new instance of AdapterManager.
7 8 9 10 11 |
# File 'lib/nab/adapter_manager.rb', line 7 def initialize @adapters = Hash.new @write_adapter = FileWriter @strip_dirs = nil end |
Instance Attribute Details
#strip_dirs ⇒ Object
Returns the value of attribute strip_dirs.
5 6 7 |
# File 'lib/nab/adapter_manager.rb', line 5 def strip_dirs @strip_dirs end |
#write_adapter ⇒ Object
Returns the value of attribute write_adapter.
5 6 7 |
# File 'lib/nab/adapter_manager.rb', line 5 def write_adapter @write_adapter end |
Instance Method Details
#get(type) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/nab/adapter_manager.rb', line 13 def get(type) if @adapters.key? type Nab::Log.debug "Retrieving cached adapter #{@adapters[type]}" @adapters[type] else klass = Nab.const_get "#{type}Adapter" Nab::Log.debug "Creating new #{type}Adapter" @adapters[type] = klass.new Nab::Log.debug "Setting write_adapter to #{write_adapter} for #{type}" @adapters[type].write_adapter = write_adapter Nab::Log.debug "Setting strip_dirs to #{strip_dirs} for #{type}" @adapters[type].strip_dirs = strip_dirs @adapters[type] end end |