Module: Foreigner
- Defined in:
- lib/foreigner.rb,
lib/foreigner/schema_dumper.rb,
lib/foreigner/connection_adapters/sql_2003.rb,
lib/foreigner/connection_adapters/mysql_adapter.rb,
lib/foreigner/connection_adapters/postgresql_adapter.rb,
lib/foreigner/connection_adapters/abstract/schema_statements.rb,
lib/foreigner/connection_adapters/abstract/schema_definitions.rb
Defined Under Namespace
Modules: ConnectionAdapters, SchemaDumper
Class Method Summary
collapse
Class Method Details
21
22
23
|
# File 'lib/foreigner.rb', line 21
def configured_adapter
ActiveRecord::Base.connection.adapter_name.downcase
end
|
.load_adapter! ⇒ Object
15
16
17
18
19
|
# File 'lib/foreigner.rb', line 15
def load_adapter!
if adapters.key?(configured_adapter)
require adapters[configured_adapter]
end
end
|
.on_load(&block) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/foreigner.rb', line 25
def on_load(&block)
if defined?(Rails) && Rails.version >= '3.0'
ActiveSupport.on_load :active_record do
unless ActiveRecord::Base.connected?
ActiveRecord::Base.configurations = Rails.application.config.database_configuration
ActiveRecord::Base.establish_connection
end
block.call
end
else
yield
end
end
|
.register(adapter_name, file_name) ⇒ Object
11
12
13
|
# File 'lib/foreigner.rb', line 11
def register(adapter_name, file_name)
adapters[adapter_name] = file_name
end
|