I’ve found horrible behavior inside dry-transaction gem and can’t find the motivation behind it. Possibly it is a bug. Please come take a look:
As stated in the docs -
Each instance method must accept an input argument and return an output wrapped in a Right (for success) or Left (for failure)
But the input is never meant to be
Right. There is an issue with step adapters in my opinion:
require "dry/transaction" LOG = Logger.new(STDOUT) class CreateUser include Dry::Transaction step :process try :validate, catch: StandardError step :persist def process(input) LOG.info(input) Right('process') end def validate(input) LOG.info(input) Right('validate') end def persist(input) LOG.info(input) Right('persist') end end CreateUser.new.call('start') I, [2017-08-07T14:43:34.045072 #80621] INFO -- : start I, [2017-08-07T14:43:34.045270 #80621] INFO -- : process I, [2017-08-07T14:43:34.045344 #80621] INFO -- : Right("validate") => Right("persist")
And what is broken is this that a
try step adapter did not extracted value from returned
Either instance as
step adapter does. That breaks the agility and intercheageability of the operations.
What am i missing? If it is a bug - I can submit a PR with a fix for that.