diff --git a/lib/dry/transaction/callable.rb b/lib/dry/transaction/callable.rb index 139460d..29b42cd 100644 --- a/lib/dry/transaction/callable.rb +++ b/lib/dry/transaction/callable.rb @@ -31,6 +31,9 @@ def initialize(operation) def call(*args, &block) if arity.zero? operation.(&block) + elsif args.last.is_a?(Hash) && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.0") + *prefix, last = args + operation.(*prefix, **last, &block) else operation.(*args, &block) end diff --git a/lib/dry/transaction/instance_methods.rb b/lib/dry/transaction/instance_methods.rb index adf0c13..ab3c117 100644 --- a/lib/dry/transaction/instance_methods.rb +++ b/lib/dry/transaction/instance_methods.rb @@ -16,7 +16,7 @@ module InstanceMethods def initialize(steps: (self.class.steps), listeners: nil, **operations) @steps = steps.map { |step| - operation = resolve_operation(step, operations) + operation = resolve_operation(step, **operations) step.with(operation: operation) } @operations = operations diff --git a/spec/integration/passing_step_arguments_spec.rb b/spec/integration/passing_step_arguments_spec.rb index 08c1cec..c0035bf 100644 --- a/spec/integration/passing_step_arguments_spec.rb +++ b/spec/integration/passing_step_arguments_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true RSpec.describe 'Passing additional arguments to step operations' do - let(:call_transaction) { transaction.with_step_args(step_options).call(input) } + let(:call_transaction) { transaction.with_step_args(**step_options).call(input) } let(:transaction) { Class.new do