mirror of
https://github.com/mperham/connection_pool
synced 2023-03-27 23:22:21 -04:00
Ruby 3.0: split positional/keyword args (#143)
This commit is contained in:
parent
3eaba661b8
commit
e9c00d61f4
2 changed files with 14 additions and 5 deletions
|
@ -32,9 +32,17 @@ class ConnectionPool
|
|||
|
||||
# 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
|
||||
|
|
|
@ -8,8 +8,8 @@ class TestConnectionPool < Minitest::Test
|
|||
@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 @@ class TestConnectionPool < Minitest::Test
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue