Sha256: bc8a88936bcad6126a6d235eb719210216fe998bff4b30c510c1205b0a78aa71

Contents?: true

Size: 1 KB

Versions: 23

Compression:

Stored size: 1 KB

Contents

ActiveRecord::ConnectionAdapters::ConnectionHandler.class_eval do
  # The only difference here is that we use klass.connection_pool_name
  # instead of klass.name as the pool key
  def retrieve_connection_pool(klass)
    pool = @connection_pools[klass.connection_pool_name]
    return pool if pool
    return nil if ActiveRecord::Base == klass
    retrieve_connection_pool klass.superclass
  end

  def remove_connection(klass)
    pool = @connection_pools[klass.connection_pool_name]
    @connection_pools.delete_if { |key, value| value == pool }
    pool.disconnect! if pool
    pool.spec.config if pool
  end
end

ActiveRecord::Base.singleton_class.class_eval do
  def establish_connection_with_connection_pool_name(spec = nil)
    case spec
    when ActiveRecord::Base::ConnectionSpecification
      connection_handler.establish_connection(connection_pool_name, spec)
    else
      establish_connection_without_connection_pool_name(spec)
    end
  end
  alias_method_chain :establish_connection, :connection_pool_name
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
active_record_shards-2.5.10 lib/active_record_shards/connection_pool.rb
active_record_shards-2.5.9 lib/active_record_shards/connection_pool.rb
active_record_shards-2.5.8 lib/active_record_shards/connection_pool.rb
active_record_shards-2.5.7 lib/active_record_shards/connection_pool.rb
active_record_shards-2.5.6 lib/active_record_shards/connection_pool.rb
active_record_shards-2.5.5 lib/active_record_shards/connection_pool.rb
active_record_shards-2.5.4 lib/active_record_shards/connection_pool.rb
active_record_shards-2.5.3 lib/active_record_shards/connection_pool.rb
active_record_shards-2.5.2 lib/active_record_shards/connection_pool.rb
active_record_shards-2.5.1 lib/active_record_shards/connection_pool.rb
active_record_shards-2.5.0 lib/active_record_shards/connection_pool.rb
active_record_shards-2.4.5 lib/active_record_shards/connection_pool.rb
active_record_shards-2.4.4 lib/active_record_shards/connection_pool.rb
active_record_shards-2.4.3 lib/active_record_shards/connection_pool.rb
active_record_shards-2.4.2 lib/active_record_shards/connection_pool.rb
active_record_shards-2.4.1 lib/active_record_shards/connection_pool.rb
active_record_shards-2.3.1 lib/active_record_shards/connection_pool.rb
active_record_shards-2.3.0 lib/active_record_shards/connection_pool.rb
active_record_shards-2.2.0 lib/active_record_shards/connection_pool.rb
active_record_shards-2.0.0 lib/active_record_shards/connection_pool.rb