From dbdacaf7f8e753dc2d2099b90f77b740278e35d0 Mon Sep 17 00:00:00 2001 From: tamsin johnson Date: Wed, 26 Apr 2023 14:18:15 -0700 Subject: [PATCH] Hyrax::Transactions::Transaction#with_step_args Ruby 3 compatibility --- lib/hyrax/transactions/transaction.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/hyrax/transactions/transaction.rb b/lib/hyrax/transactions/transaction.rb index 0658337769..dfbcca53bf 100644 --- a/lib/hyrax/transactions/transaction.rb +++ b/lib/hyrax/transactions/transaction.rb @@ -95,7 +95,8 @@ def initialize(container: Container, steps:) def call(value) Success( steps.inject(value) do |val, step_name| - yield container[step_name].call(val, *step_arguments_for(step_name)) + args = step_arguments_for(step_name) + yield container[step_name].call(val, *args[0..-2], **Hash(args[-1])) end ) end @@ -119,7 +120,7 @@ def call(value) # tx = Hyrax::Transactions::Transaction.new(steps: [:first_step, :second_step]) # result = tx.with_step_args(second_step: {named_parameter: :param_value}).call(:value) # - def with_step_args(args) + def with_step_args(**args) raise(ArgumentError, key_err_msg(args.keys)) if args.keys.any? { |key| !step?(key) }