Created
January 9, 2016 18:15
-
-
Save dkomanov/8c0eb2f377e070e8a40a to your computer and use it in GitHub Desktop.
[scala] result code: fold
This file contains 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
def processRequestCollections(userId: UUID, requestId: UUID): BusinessResult = { | |
getUser(userId).fold(BusinessResult.UserNotFound)(user => { | |
getRequestById(requestId).fold(BusinessResult.RequestNotFound)(request => { | |
checkAccess(request, user).toOption.fold(BusinessResult.NotOwner)(_ => BusinessResult.Ok) | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment