Sha256: d40d2e2b87979c926d1ea869fb144de755e70581e52e53a89d465c00fd665d8b

Contents?: true

Size: 1.29 KB

Versions: 11

Compression:

Stored size: 1.29 KB

Contents

require "pathname"
require "active_record"
require "active_record/version"

module ActiveRecord::Import
  ADAPTER_PATH = "activerecord-import/active_record/adapters".freeze

  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

  # Loads the import functionality for a specific database adapter
  def self.require_adapter(adapter)
    require File.join(ADAPTER_PATH, "/#{base_adapter(adapter)}_adapter")
  rescue LoadError
    # fallback
  end

  # Loads the import functionality for the passed in ActiveRecord connection
  def self.load_from_connection_pool(connection_pool)
    adapter =
      if connection_pool.respond_to?(:db_config) # ActiveRecord >= 6.1
        connection_pool.db_config.adapter
      else
        connection_pool.spec.config[:adapter]
      end
    require_adapter adapter
  end
end

require 'activerecord-import/import'
require 'activerecord-import/active_record/adapters/abstract_adapter'
require 'activerecord-import/synchronize'
require 'activerecord-import/value_sets_parser'

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
activerecord-import-1.4.0 lib/activerecord-import/base.rb
activerecord-import-1.3.0 lib/activerecord-import/base.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/activerecord-import-1.2.0/lib/activerecord-import/base.rb
activerecord-import-1.2.0 lib/activerecord-import/base.rb
activerecord-import-1.1.0 lib/activerecord-import/base.rb
activerecord-import-1.0.8 lib/activerecord-import/base.rb
activerecord-import-1.0.7 lib/activerecord-import/base.rb
activerecord-import-1.0.6 lib/activerecord-import/base.rb
activerecord-import-1.0.5 lib/activerecord-import/base.rb
activerecord-import-1.0.4 lib/activerecord-import/base.rb
activerecord-import-1.0.3 lib/activerecord-import/base.rb