Created
October 21, 2015 01:49
-
-
Save nthj/df5aec9c5507e81e2d41 to your computer and use it in GitHub Desktop.
Fun shorthand for raising exceptions from Rails callbacks
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 StandardError | |
# Accountant::CannotDestroyFinancialData = Class.new(Exception) | |
# before_destroy(&Accountant::CannotDestroyFinancialData) | |
def self.to_proc | |
e = self; -> { raise e } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment