diff --git a/lib/connection_pool.rb b/lib/connection_pool.rb index 3b166bb..6e049e1 100644 --- a/lib/connection_pool.rb +++ b/lib/connection_pool.rb @@ -75,7 +75,9 @@ class ConnectionPool nil end - class Wrapper + class Wrapper < ::BasicObject + METHODS = [:with, :with_connection] + def initialize(options = {}, &block) @pool = ::ConnectionPool.new(options, &block) end @@ -88,7 +90,7 @@ class ConnectionPool alias_method :with_connection, :with def respond_to?(id, *args) - super(id, *args) || @pool.with { |c| c.respond_to?(id, *args) } + METHODS.include?(id) || @pool.with { |c| c.respond_to?(id, *args) } end def method_missing(name, *args, &block) diff --git a/test/test_connection_pool.rb b/test/test_connection_pool.rb index f5574eb..608de48 100644 --- a/test/test_connection_pool.rb +++ b/test/test_connection_pool.rb @@ -72,7 +72,10 @@ class TestConnectionPool < MiniTest::Unit::TestCase assert_equal 2, pool.do_something assert_equal 5, pool.do_something_with_block { 3 } assert_equal 6, pool.with { |net| net.fast } + end + def test_passthru_respond_to + pool = ConnectionPool.wrap(:timeout => 0.1, :size => 1) { NetworkConnection.new } assert pool.respond_to?(:with) assert pool.respond_to?(:do_something) assert pool.respond_to?(:do_magic)