Sha256: 491912720ccaea5ecf9126309b11257ff9e6e321703cd14133c53a2c6a6c9606

Contents?: true

Size: 1 KB

Versions: 5

Compression:

Stored size: 1 KB

Contents

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

module ActiveRecord::Import
  AdapterPath = File.join File.expand_path(File.dirname(__FILE__)), "/active_record/adapters"

  # Loads the import functionality for a specific database adapter
  def self.require_adapter(adapter)
    require File.join(AdapterPath,"/abstract_adapter")
    require File.join(AdapterPath,"/#{adapter}_adapter")
  end

  # Loads the import functionality for the passed in ActiveRecord connection
  def self.load_from_connection(connection)
    import_adapter = "ActiveRecord::Import::#{connection.class.name.demodulize}::InstanceMethods"
    unless connection.class.ancestors.map(&:name).include?(import_adapter)
      config = connection.instance_variable_get :@config
      require_adapter config[:adapter]
    end
  end
end


this_dir = Pathname.new File.dirname(__FILE__)
require this_dir.join("import").to_s
require this_dir.join("active_record/adapters/abstract_adapter").to_s
require this_dir.join("synchronize").to_s

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
Empact-activerecord-import-0.3.5 lib/activerecord-import/base.rb
Empact-activerecord-import-0.3.4 lib/activerecord-import/base.rb
activerecord-import-0.2.8 lib/activerecord-import/base.rb
activerecord-import-0.2.8.rc3 lib/activerecord-import/base.rb
activerecord-import-0.2.8.rc2 lib/activerecord-import/base.rb