Closed TastyPi closed 1 year ago
Ah this is because I misunderstood how the library intends for inputs to be passed to steps.
For others who run into this, the first parameter passed to the step is its input. Only one argument is passed to steps, which is either the value passed to call
or the value of a successful previous step. All extra arguments to a step are set using with_step_args
.
So the correct way to do my example would be:
#!/usr/bin/env ruby
require "dry/container"
require "dry/transaction"
Container = Dry::Container.new
Container.register(:foo) do |input|
Dry::Monads::Result::Success.new(input[:foo])
end
class Tr
include Dry::Transaction(container: Container)
step :bar, with: :foo
def bar(input)
super({foo: input[:bar]})
end
end
puts Tr.new.call(bar: "baz")
Describe the bug
Keyword parameters are not passed through properly when wrapping step.
To Reproduce
Results in this error:
Expected behavior
Should print
Success("baz")
My environment