Skip to content

Commit

Permalink
mperham#113 expose pool from Wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
ook committed Feb 28, 2019
1 parent a08fb8f commit 3e92a02
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/connection_pool.rb
Expand Up @@ -109,12 +109,16 @@ def available
private

class Wrapper < ::BasicObject
METHODS = [:with, :pool_shutdown]
METHODS = [:with, :pool_shutdown, :pool]

def initialize(options = {}, &block)
@pool = options.fetch(:pool) { ::ConnectionPool.new(options, &block) }
end

def pool
@pool
end

def with(&block)
@pool.with(&block)
end
Expand Down
5 changes: 5 additions & 0 deletions test/test_connection_pool.rb
Expand Up @@ -474,6 +474,11 @@ def test_shutdown_is_executed_for_all_connections_in_wrapped_pool
assert_equal [["shutdown"]] * 3, recorders.map { |r| r.calls }
end

def test_wrapper_pool
wrapper = ConnectionPool::Wrapper.new { NetworkConnection.new }
assert_equal ConnectionPool, wrapper.pool.class
end

def test_wrapper_method_missing
wrapper = ConnectionPool::Wrapper.new { NetworkConnection.new }

Expand Down

0 comments on commit 3e92a02

Please sign in to comment.