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

Remove ruby version check from callable.rb #147

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions lib/dry/transaction/callable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def initialize(operation)
def call(*args, &block)
if arity.zero?
operation.(&block)
elsif ruby_27_last_arg_hash?(args)
elsif last_arg_hash?(args)
*prefix, last = args
operation.(*prefix, **last, &block)
else
Expand All @@ -47,11 +47,9 @@ def call(*args, &block)
# passed to dry-rb validators.
# In this case, it's better to leave the object as it's existing type, rather than implicitly
# convert it in to a hash with the double-splat (**) operator.
def ruby_27_last_arg_hash?(args)
def last_arg_hash?(args)
kwargs = args.last
kwargs.instance_of?(Hash) &&
!kwargs.empty? &&
Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.0")
kwargs.instance_of?(Hash) && !kwargs.empty?
end
end
end
Expand Down