class Nab::AdapterManager

Attributes

strip_dirs[RW]
write_adapter[RW]

Public Class Methods

new() click to toggle source
# File lib/nab/adapter_manager.rb, line 7
def initialize
  @adapters = Hash.new
  @write_adapter = FileWriter
  @strip_dirs = nil
end

Public Instance Methods

get(type) click to toggle source
# 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