dry-transaction
dry-transaction copied to clipboard
Nested transactions with step arguments fail with ArgumentError
When calling a transaction from another transaction the call fails if step_args
are provided.
Error message:
ArgumentError:
wrong number of arguments (given 2, expected 0..1)
# ./lib/dry/transaction/instance_methods.rb:25:in `call'
pseudocode:
nested = Class.new do
include Dry::Transaction
step :process
def process(input, *args); Success; end
end.new
# register nested in container C
root = Class.new do
include Dry::Transaction(container: C)
step :root, with: nested
end.new
root.call # ok
root.with_step_args(root: 'foo').call # error
The issue seems to be that the arguments can't be passed down to the nested transaction but the lib tries to.
I've prepared a test case that demonstrates this:
https://github.com/dry-rb/dry-transaction/pull/125
Short discussion on discourse:
https://discourse.dry-rb.org/t/nested-transactions-with-step-arguments-buggy/757