Class: ActiveRecord::ConnectionAdapters::ConnectionHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record_host_pool/connection_adapter_mixin.rb

Instance Method Summary collapse

Instance Method Details

#establish_connection(owner, spec) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/active_record_host_pool/connection_adapter_mixin.rb', line 83

def establish_connection(owner, spec)
  if ActiveRecord::VERSION::MAJOR >= 4
    @class_to_pool.clear
    raise RuntimeError, "Anonymous class is not allowed." unless owner.name
    owner_to_pool[owner.name] = ActiveRecordHostPool::PoolProxy.new(spec)
  elsif ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR == 2
    @connection_pools[spec] ||= ActiveRecordHostPool::PoolProxy.new(spec)
    @class_to_pool[owner] = @connection_pools[spec]
  else
    @connection_pools[owner] = ActiveRecordHostPool::PoolProxy.new(spec)
  end
end