You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 7, 2018. It is now read-only.
Right now RoQua adds callbacks to interactors, which are used to communicate result state and execute bits of controller logic (redirect_to @post for success vs render action: :edit for failure):
classPostsControllerdefupdateinteraction=PostUpdate.new(params)interaction.on_success{redirect_tointeraction.post}interaction.on_failure{renderaction: :edit,locals: {post: interaction.post}}interaction.callendendclassPostUpdate < Interactordefon_success(&block)@on_success=blockend# same for on_failuredefexecuteifrand > 0.5@on_success.callelse@on_failure.callendendend
We could add it like that to Pavlov, but another way would be to support returning "status objects" from interactors:
classPostsControllerdefupdateresult=PostUpdate.new(params).callresult.on_success{redirect_tointeraction.post}result.on_failure{renderaction: :edit,locals: {post: result.post}}endendclassPostUpdate < InteractorclassPostUpdateStatus < Struct.new(:status,:post)defon_successyieldifstatus == :successend# same for on_failureenddefexecuteifrand > 0.5PostUpdateStatus.new(:success,post)elsePostUpdateStatus.new(:failure,post)endendend
For us, both would work equally well. Which would be your preference?