Module: ActiveRecord::Import

Defined in:
lib/activerecord-import/import.rb,
lib/activerecord-import/version.rb,
lib/activerecord-import/value_sets_parser.rb,
lib/activerecord-import/base.rb

Overview

:nodoc:

Defined Under Namespace

Modules: AbstractAdapter, ConnectionAdapters, EMMysql2Adapter, ImportSupport, Mysql2Adapter, MysqlAdapter, OnDuplicateKeyUpdateSupport, PostgreSQLAdapter, SQLite3Adapter Classes: MissingColumnError, Result, Validator, ValueSetTooLargeError, ValueSetsBytesParser, ValueSetsRecordsParser

Constant Summary collapse

VERSION =
"1.0.2".freeze
ADAPTER_PATH =
"activerecord-import/active_record/adapters".freeze

Class Method Summary collapse

Class Method Details

.base_adapter(adapter) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/activerecord-import/base.rb', line 8

def self.base_adapter(adapter)
  case adapter
  when 'mysql2_makara' then 'mysql2'
  when 'mysql2spatial' then 'mysql2'
  when 'spatialite' then 'sqlite3'
  when 'postgresql_makara' then 'postgresql'
  when 'makara_postgis' then 'postgresql'
  when 'postgis' then 'postgresql'
  when 'cockroachdb' then 'postgresql'
  else adapter
  end
end

.load_from_connection_pool(connection_pool) ⇒ Object

Loads the import functionality for the passed in ActiveRecord connection


29
30
31
# File 'lib/activerecord-import/base.rb', line 29

def self.load_from_connection_pool(connection_pool)
  require_adapter connection_pool.spec.config[:adapter]
end

.require_adapter(adapter) ⇒ Object

Loads the import functionality for a specific database adapter


22
23
24
25
26
# File 'lib/activerecord-import/base.rb', line 22

def self.require_adapter(adapter)
  require File.join(ADAPTER_PATH, "/#{base_adapter(adapter)}_adapter")
rescue LoadError
  # fallback
end