Skip to content

Instantly share code, notes, and snippets.

@vitaly-pushkar
Last active January 31, 2020 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vitaly-pushkar/ba2faa3e78d7c3700ee488cc52ea65bd to your computer and use it in GitHub Desktop.
Save vitaly-pushkar/ba2faa3e78d7c3700ee488cc52ea65bd to your computer and use it in GitHub Desktop.
From the blog post "Error Handling with Either Monads in Ruby"
patch '/users/:id/' do
result = UserUpdater.new(User, config.mailer).call(params).to_result
# a simple, "unambitious" version
if result.success?
result.sucess.to_json
else
{error: result.failure}.to_json
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment