The Dry::Transacation documenatation speaks of an enqueue step adapter in its documentation.
However, I was unable to find a real world implementation.
This is why I came up with this in a PoC. I hope this is useful to someone.
You must call #deliver_later or #perform_later yourself.
enqueue will ensure, that it will be called after a potentially open ActiveRecord transaction has been finished.
around :transaction
step :do_fun_stuff_you_want_to_save
enqueue :send_welcome_email
step :do_other_cool_stuff
def send_welcome_email
job = AccountMailer.welcome(user).deliver_later
if job
Success(job)
else
Failure()
end
end