Created
September 7, 2019 19:24
-
-
Save flash-gordon/eaaf70d120eac47fc3e07831fdaf32e3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Prelude | |
class Monadic | |
include Dry::Monads[:maybe, :result, :do] | |
def call(id, item_id) | |
users = [:user] | |
items = [] | |
user, item = yield Maybe(users[id]).and(Maybe(items[item_id])).to_result { | |
'User not found' | |
} | |
Success(user: user, item: item) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment