Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

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