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, ValueSetsBytesParser, ValueSetsRecordsParser

Constant Summary collapse

VERSION =
"0.18.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
# 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 'postgis' then 'postgresql'
  else adapter
  end
end

.load_from_connection_pool(connection_pool) ⇒ Object

Loads the import functionality for the passed in ActiveRecord connection



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

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



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

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