diff --git a/lib/connection_pool/wrapper.rb b/lib/connection_pool/wrapper.rb index 2366b46..249d5eb 100644 --- a/lib/connection_pool/wrapper.rb +++ b/lib/connection_pool/wrapper.rb @@ -32,9 +32,17 @@ def respond_to?(id, *args) # rubocop:disable Style/MethodMissingSuper # rubocop:disable Style/MissingRespondToMissing - def method_missing(name, *args, &block) - with do |connection| - connection.send(name, *args, &block) + if ::RUBY_VERSION >= "3.0.0" + def method_missing(name, *args, **kwargs, &block) + with do |connection| + connection.send(name, *args, **kwargs, &block) + end + end + else + def method_missing(name, *args, &block) + with do |connection| + connection.send(name, *args, &block) + end end end # rubocop:enable Style/MethodMissingSuper diff --git a/test/test_connection_pool.rb b/test/test_connection_pool.rb index b7ae9e5..2780bbd 100644 --- a/test/test_connection_pool.rb +++ b/test/test_connection_pool.rb @@ -8,8 +8,8 @@ def initialize @x = 0 end - def do_something - @x += 1 + def do_something(*_args, increment: 1) + @x += increment sleep SLEEP_TIME @x end @@ -332,6 +332,7 @@ def test_passthru assert_equal 2, pool.do_something assert_equal 5, pool.do_something_with_block { 3 } assert_equal 6, pool.with { |net| net.fast } + assert_equal 8, pool.do_something(increment: 2) end def test_passthru_respond_to