Module: ActiveRecord::Import

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

Overview

:nodoc:

Defined Under Namespace

Modules: AbstractAdapter, ConnectionAdapters, ImportSupport, Mysql2Adapter, MysqlAdapter, OnDuplicateKeyUpdateSupport, PostgreSQLAdapter, SQLite3Adapter Classes: MissingColumnError, Result

Constant Summary collapse

VERSION =
"0.5.0"
AdapterPath =
File.join File.expand_path(File.dirname(__FILE__)), "/active_record/adapters"

Class Method Summary collapse

Class Method Details

.base_adapter(adapter) ⇒ Object



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

def self.base_adapter(adapter)
  case adapter
  when 'mysqlspatial' then 'mysql'
  when 'mysql2spatial' then 'mysql2'
  when 'spatialite' then 'sqlite3'
  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



25
26
27
# File 'lib/activerecord-import-rails4/base.rb', line 25

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



19
20
21
22
# File 'lib/activerecord-import-rails4/base.rb', line 19

def self.require_adapter(adapter)
  require File.join(AdapterPath,"/abstract_adapter")
  require File.join(AdapterPath,"/#{base_adapter(adapter)}_adapter")
end