Last active
August 27, 2015 11:01
-
-
Save tygern/a6622c7ee5f9d73e1508 to your computer and use it in GitHub Desktop.
Returning response objects in Ruby - creation service after
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
| class UsersCreator | |
| def create(attributes) | |
| repository_response = UserRepository.new.create(attributes) | |
| return repository_response unless repository_response.success | |
| user = repository_response.entity | |
| notifier_response = UserNotifier.new(user).send_signup_confirmation | |
| ServiceResponse.new( | |
| success: notifier_response.success, | |
| entity: user, | |
| errors: notifier_response.errors | |
| ) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment