AaronLasseigne / active_interaction

:briefcase: Manage application specific business logic.
MIT License
2.07k stars 137 forks source link

Add optional block for Callable#result #528

Closed Codcore closed 2 years ago

Codcore commented 2 years ago

So we can do like (pseudo code):

UserCreate.run(params: user_params) do |u|
  if u
    redirect_to users_path
  else
    render 'users/new'
  end
end
AaronLasseigne commented 2 years ago

You can do this with tap. I'd prefer to save the block for some possible future use.

UserCreate.run(params: user_params).tap do |u|
  if u
    redirect_to users_path
  else
    render 'users/new'
  end
end