Sha256: 73f3caa89b7deb64c2eb231bce9c7db36a451d7cf492f7d14e17ecd43e0f865f

Contents?: true

Size: 777 Bytes

Versions: 3

Compression:

Stored size: 777 Bytes

Contents

require_relative './database_connection'
require_relative './database/mysql'
require_relative './database/postgres'

module CsvFastImporter

  # Build corresponding CsvFastImporter database implementation based current adapter (fetched from DatabaseConnection)
  module DatabaseFactory
    DATABASES = { postgresql: CsvFastImporter::Database::Postgres,
                  mysql2: CsvFastImporter::Database::Mysql
                }

    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
csv_fast_importer-1.2.0 lib/csv_fast_importer/database_factory.rb
csv_fast_importer-1.1.0 lib/csv_fast_importer/database_factory.rb
csv_fast_importer-1.0.0 lib/csv_fast_importer/database_factory.rb