Class: Denouncer::Notifiers::BaseNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/denouncer/notifiers/base_notifier.rb

Direct Known Subclasses

AmqpNotifier, ConsoleNotifier, SmtpNotifier

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options)
  if options[:application_name].nil? || !options[:application_name].is_a?(String)
    raise "Invalid configuration hash: No valid :application_name given"
  end
  opts = set_configuration!(options).dup
  @config = opts
end

Instance Attribute Details

#configObject (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_timestampObject

Returns the current timestamp in utc is8601 format



17
18
19
# File 'lib/denouncer/notifiers/base_notifier.rb', line 17

def get_current_timestamp
  Time.now.utc.iso8601
end

#notify(error, metadata = nil) ⇒ Object

Sends a notification.

Parameters:

  • error (StandardError)
  • metadata (Hash) (defaults to: nil)


29
30
31
# File 'lib/denouncer/notifiers/base_notifier.rb', line 29

def notify(error,  = nil)
  raise NotImplementedException("This method needs to be implemented in a sub-class!")
end

#set_configuration!(options) ⇒ Object



21
22
23
# File 'lib/denouncer/notifiers/base_notifier.rb', line 21

def set_configuration!(options)
  raise NotImplementedException("This method needs to be implemented in a sub-class!")
end