1
0
Fork 0
mirror of https://github.com/mperham/connection_pool synced 2023-03-27 23:22:21 -04:00

Restore Wrapper inheriting from BasicObject. Closes #16.

This commit is contained in:
Damian Janowski 2012-12-18 13:50:12 -03:00
parent 29cd6d7b56
commit f0cb4ea11f
2 changed files with 7 additions and 2 deletions

View file

@ -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)

View file

@ -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)