Updated how activerecord-import loads so it is done after a connection is established in ActiveRecord. This supports loading import for multiple adapters automatically w/o having to have a person require those specifically.
This commit is contained in:
parent
6c6a0d22b9
commit
cb542a86f4
3 changed files with 27 additions and 8 deletions
|
@ -11,13 +11,17 @@ module ActiveRecord::Import
|
|||
require File.join(AdapterPath,"/#{adapter}_adapter")
|
||||
end
|
||||
|
||||
# Loads the import functionality for the current ActiveRecord::Base.connection
|
||||
def self.load
|
||||
config = ActiveRecord::Base.connection.instance_variable_get :@config
|
||||
require_adapter config[:adapter]
|
||||
# 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")
|
||||
require this_dir.join("active_record/adapters/abstract_adapter")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue