Method: DBA::Load#call

Defined in:
lib/dba/load.rb

#call(path) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dba/load.rb', line 13

def call(path)
  file_list(path).each do |file|
    extension = File.extname(file)

    adapter = ADAPTERS.fetch(extension) { raise DBA::Error, 'unsupported file extension' }

    adapter = DBA.const_get(adapter)

    table_name = File.basename(file, extension).to_sym

    adapter.load(file, database, table_name)
  end
end