Class: Denouncer::Notifiers::BaseNotifier
- Inherits:
-
Object
- Object
- Denouncer::Notifiers::BaseNotifier
- Defined in:
- lib/denouncer/notifiers/base_notifier.rb
Direct Known Subclasses
AirbrakeNotifier, AmqpNotifier, ConsoleNotifier, HoneybadgerNotifier, SmtpNotifier
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#get_current_timestamp ⇒ Object
Returns the current timestamp in utc is8601 format.
-
#get_error_cause(error) ⇒ Object
returns the given error’s cause if available.
-
#initialize(options) ⇒ BaseNotifier
constructor
A new instance of BaseNotifier.
-
#name ⇒ String
The name for the notifier.
-
#notify(error, metadata = nil) ⇒ Object
Sends a notification.
- #set_configuration!(options) ⇒ Object
Constructor Details
#initialize(options) ⇒ BaseNotifier
Returns a new instance of BaseNotifier.
8 9 10 11 12 13 14 |
# File 'lib/denouncer/notifiers/base_notifier.rb', line 8 def initialize() if [:application_name].nil? || ![:application_name].is_a?(String) raise "Invalid configuration hash: No valid :application_name given" end opts = set_configuration!().dup @config = opts end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/denouncer/notifiers/base_notifier.rb', line 6 def config @config end |
Instance Method Details
#get_current_timestamp ⇒ Object
Returns the current timestamp in utc is8601 format
17 18 19 |
# File 'lib/denouncer/notifiers/base_notifier.rb', line 17 def Time.now.utc end |
#get_error_cause(error) ⇒ Object
returns the given error’s cause if available
22 23 24 25 26 27 28 |
# File 'lib/denouncer/notifiers/base_notifier.rb', line 22 def get_error_cause(error) if error.respond_to? :cause error.cause else nil end end |
#name ⇒ String
Returns the name for the notifier.
31 32 33 |
# File 'lib/denouncer/notifiers/base_notifier.rb', line 31 def name raise NotImplementedException("This method needs to be implemented in a sub-class!") end |
#notify(error, metadata = nil) ⇒ Object
Sends a notification.
43 44 45 |
# File 'lib/denouncer/notifiers/base_notifier.rb', line 43 def notify(error, = nil) raise NotImplementedException("This method needs to be implemented in a sub-class!") end |
#set_configuration!(options) ⇒ Object
35 36 37 |
# File 'lib/denouncer/notifiers/base_notifier.rb', line 35 def set_configuration!() raise NotImplementedException("This method needs to be implemented in a sub-class!") end |