Skip to content

Commit

Permalink
Merge pull request #6021 from samvera/step-args-kwds
Browse files Browse the repository at this point in the history
Hyrax::Transactions::Transaction#with_step_args Ruby 3 compatibility
  • Loading branch information
dlpierce authored Apr 27, 2023
2 parents 0577f01 + dbdacaf commit 4a198ec
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/hyrax/transactions/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) }

Expand Down

0 comments on commit 4a198ec

Please sign in to comment.