Created
August 2, 2012 08:24
-
-
Save elia/c0eb3b5015d919e909a2 to your computer and use it in GitHub Desktop.
Notify deprecations via ExceptionNotifier
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
ActiveSupport::Deprecation.behavior = DeprecationNotifier.new |
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
require 'ostruct' | |
class DeprecationNotifier | |
class DeprecationError < StandardError | |
def initialize message, callstack | |
super message | |
set_backtrace callstack | |
end | |
end | |
def call message, callstack | |
# Keep the default behavior at work | |
ActiveSupport::Deprecation.default_behavior(message, callstack) | |
# Let's mimic the controller exception :\ | |
exception = DeprecationError.new(message, callstack) | |
request = OpenStruct.new(:env => {}, :session_options => {}) | |
ExceptionNotification::Notifier.deliver_exception_notification(exception, self, request, data) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment