Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby 3.0: split positional/keyword args #143

Merged
merged 1 commit into from Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions lib/connection_pool/wrapper.rb
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions test/test_connection_pool.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down