Module: CsvFastImporter::DatabaseFactory

Defined in:
lib/csv_fast_importer/database_factory.rb

Overview

Build corresponding CsvFastImporter database implementation based current adapter (fetched from DatabaseConnection)

Constant Summary collapse

DATABASES =
{ postgresql: CsvFastImporter::Database::Postgres,
  mysql2: CsvFastImporter::Database::Mysql
}

Class Method Summary collapse

Class Method Details

.buildObject



13
14
15
16
17
# File 'lib/csv_fast_importer/database_factory.rb', line 13

def self.build
  adapter = CsvFastImporter::DatabaseConnection.adapter_name
  return DATABASES[adapter].new(CsvFastImporter::DatabaseConnection.base_connection) if DATABASES.has_key?(adapter)
  raise "Database adapter #{adapter} not supported by CsvFastImporter. Only #{DATABASES.keys.join(", ")} are supported"
end