Last active
August 27, 2015 16:21
-
-
Save tygern/6c16c367045833330172 to your computer and use it in GitHub Desktop.
Returning response objects in Ruby - creation service before
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) | |
| user = UserRepository.new.create(attributes) | |
| if user.nil? || !user.persisted? | |
| return user | |
| end | |
| notification_success = UserNotifier.new(user).send_signup_confirmation | |
| unless notification_success | |
| user.errors[:base] << "Notification failed" | |
| end | |
| user | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment