Open dmaze opened 6 years ago
I found a workaround - dry-transaction
doesn't actually care that the object includes Dry::Transaction::Operation
specifically, it just uses the call
method. So you can instead replace it with Dry::Monads[:result]
directly:
class First
include Dry::Monads[:result]
def call(input)
yield Success(input + 1)
end
end
I've gotten into the habit of writing dry-transaction operations as individual classes that
include Dry::Transaction::Operation
. (It avoids the scary 5-letter "m" word.) If you use this in an operation class that's intended to be anaround
step, like so:You will get a backtrace when you run it. https://gist.github.com/dmaze/ea78510a8870089be510a55d8fb38a8e is a more complete reproduction script. Running that prints out:
More specifically, it looks like the Operation mixin wraps
#call
in a dry-matcher, and the generated method doesn't pass the block up to the user code (it looks like it might repurpose it for something else).An easy enough workaround is to
include Dry::Monads::Result::Mixin
instead.I'm running this with jruby-9.2.0.0 and the gem versions shown in the backtrace, should that turn out to matter.