-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use Rectify::Command as a simple command after upgrade to 0.12.0 #49
Comments
This is an intended change. Commands now return a hash of the events that were broadcast inside the RegisterAccount.call(@form) do
on(:ok) { |account| redirect_to account_dashboard_path(account) }
on(:invalid) { render :new }
on(:already_registered) { redirect_to login_path }
end But now you can also do: events = RegisterAccount.call(@form) Where {
:ok => account
} This in effect allows multiple return values and allows you switch on a key existing: events = RegisterAccount.call(@form)
if events.key?(:ok)
redirect_to account_dashboard_path(events[:ok])
end This just adds flexibility to how you can call commands and handle the outcomes. If you want to return of Thanks Andy |
Hi Andy, thanks for your response.
Yes, you are right. In some cases I do not use events so I replaced rectify with the SimpleCommand gem What do you think about adding register = RegisterAccount.call(@form)
if register.key?(:ok)
register.result
end |
That's an interesting idea, thanks. I'll have a think about that 👍 |
@andypike great! If you approve this idea I could add a PR for it. Just let me know! |
Hello!
In some cases I used to use
Rectify::Command
as a simple command like thisBut after upgrade to 0.12.0 it started to return hash instead of value returned by
Users::BuildFor#call
Could you change
Rectify::Command.call
to return value provided byRectify::Command#call
?Or I need to change my codebase?
Thanks
The text was updated successfully, but these errors were encountered: