5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/active_record_shards/connection_specification.rb', line 5
def establish_connection(spec = ENV["DATABASE_URL"])
spec ||= ActiveRecord::ConnectionHandling::DEFAULT_ENV.call
spec = spec.to_sym if spec.is_a?(String)
resolver = ActiveRecordShards::ConnectionSpecification::Resolver.new configurations
spec = resolver.spec(spec)
unless respond_to?(spec.adapter_method)
raise AdapterNotFound, "database configuration specifies nonexistent #{spec.config[:adapter]} adapter"
end
remove_connection
specification_cache[connection_pool_name] = spec
connection_handler.establish_connection self, spec
end
|