Skip to content

Instantly share code, notes, and snippets.

@nthj
Created October 21, 2015 01:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nthj/df5aec9c5507e81e2d41 to your computer and use it in GitHub Desktop.
Save nthj/df5aec9c5507e81e2d41 to your computer and use it in GitHub Desktop.
Fun shorthand for raising exceptions from Rails callbacks
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