From fa0861f4518e818d661e762b42a2fabfd663664d Mon Sep 17 00:00:00 2001 From: Robert robbl Schulze Date: Tue, 18 Aug 2020 23:26:15 +0200 Subject: [PATCH 1/2] Resolve ruby 2.7 deprecation warnings --- lib/dry/transaction/callable.rb | 3 +++ lib/dry/transaction/instance_methods.rb | 2 +- spec/integration/passing_step_arguments_spec.rb | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/dry/transaction/callable.rb b/lib/dry/transaction/callable.rb index 139460d..854b006 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) + *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 From b66b6e2128b9341329645caf69d365c968804299 Mon Sep 17 00:00:00 2001 From: Robert robbl Schulze Date: Wed, 19 Aug 2020 16:22:51 +0200 Subject: [PATCH 2/2] Only try to fix deprecation warning if running ruby27 --- lib/dry/transaction/callable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dry/transaction/callable.rb b/lib/dry/transaction/callable.rb index 854b006..29b42cd 100644 --- a/lib/dry/transaction/callable.rb +++ b/lib/dry/transaction/callable.rb @@ -31,7 +31,7 @@ def initialize(operation) def call(*args, &block) if arity.zero? operation.(&block) - elsif args.last.is_a?(Hash) + 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