Skip to content

Instantly share code, notes, and snippets.

@tygern
Last active August 27, 2015 16:21
Show Gist options
  • Select an option

  • Save tygern/6c16c367045833330172 to your computer and use it in GitHub Desktop.

Select an option

Save tygern/6c16c367045833330172 to your computer and use it in GitHub Desktop.
Returning response objects in Ruby - creation service before
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