class DataImp::Porter
Attributes
hash[R]
index[R]
Public Class Methods
after_all_imports()
click to toggle source
# File lib/data_imp/porter.rb, line 55 def self.after_all_imports # called after all data is processed end
before_all_imports()
click to toggle source
# File lib/data_imp/porter.rb, line 38 def self.before_all_imports # called before any data is processed end
find_importer(type)
click to toggle source
# File lib/data_imp/porter.rb, line 6 def self.find_importer type return self if type.blank? begin const_get type.classify rescue NameError => e if require_relative "porter/#{type.underscore}" retry end end rescue LoadError => e raise DataImp::NoImporter.new(type) end
new(hash, index = nil)
click to toggle source
# File lib/data_imp/porter.rb, line 19 def initialize(hash, index = nil) @hash = HashWithIndifferentAccess.new(hash) @index = index end
Public Instance Methods
after_import()
click to toggle source
# File lib/data_imp/porter.rb, line 51 def after_import # called after a record was imported end
before_import()
click to toggle source
# File lib/data_imp/porter.rb, line 42 def before_import # called for a record before import end
import()
click to toggle source
# File lib/data_imp/porter.rb, line 46 def import # called to import a record warn "Import: #{self.class.name}:#{index}:#{hash.inspect}" end
method_missing(method, *_args)
click to toggle source
# File lib/data_imp/porter.rb, line 28 def method_missing(method, *_args) return nil unless respond_to_missing?(method) value = hash[method] parse(method,value) end
on_error(e)
click to toggle source
# File lib/data_imp/porter.rb, line 59 def on_error e warn "Error: #{self.class.name}:#{index}:#{hash.inspect}" warn e end
parse(method, value)
click to toggle source
# File lib/data_imp/porter.rb, line 34 def parse method, value value # override for special handling end
respond_to_missing?(method, include_private = false)
click to toggle source
# File lib/data_imp/porter.rb, line 24 def respond_to_missing?(method, include_private = false) hash.has_key?(method) || false # super end