Last active
August 29, 2015 14:10
-
-
Save KamilLelonek/1ba97620ced153d05b6e to your computer and use it in GitHub Desktop.
Exception driven development
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 ClientsController < ActionController::API | |
def update_registration_number | |
update_registration_number_service.(registration_number) | |
render_success | |
rescue UpdateRegistrationNumber::RegistrationNumberAlreadyExist | |
render_error | |
end | |
# ... | |
end |
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 UpdateRegistrationNumber | |
RegistrationNumberAlreadyExist = Class.new(StandardError) | |
def call(registration_number) | |
raise RegistrationNumberAlreadyExist if exist?(registration_number) | |
# ... | |
end | |
# ... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/KamilLelonek/1ba97620ced153d05b6e#file-clients_controller-rb-L3
I believe you are missing the call to
.call
here.