Created
October 20, 2012 21:01
-
-
Save r38y/3924791 to your computer and use it in GitHub Desktop.
This file contains 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 Checking | |
def run | |
Rails.logger.info "Checking #{snitch.id} (#{snitch.name})..." | |
unless checkable? | |
Rails.logger.error "Snitch #{snitch.id} is not checkable" | |
return false | |
end | |
... more stuff | |
end | |
end | |
# how do I exit early from Checking#run from another method? | |
class Checking | |
def run | |
Rails.logger.info "Checking #{snitch.id} (#{snitch.name})..." | |
handle_non_checkable | |
... more stuff | |
end | |
private | |
def handle_non_checkable | |
unless checkable? | |
Rails.logger.error "Snitch #{snitch.id} is not checkable" | |
return false | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Make
handle_non_checkable
return true in the case that checkable? returns true, and make runreturn false unless handle_non_checkable
.Not exactly what you wanted, but close maybe? https://gist.github.com/3925821