Class: Nab::AdapterManager

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAdapterManager

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_dirsObject

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_adapterObject

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