Class: Rusen::Notifier
- Inherits:
-
Object
- Object
- Rusen::Notifier
- Defined in:
- lib/rusen/notifier.rb
Instance Method Summary collapse
-
#initialize(settings) ⇒ Notifier
constructor
A new instance of Notifier.
-
#notify(exception, request = nil, environment = nil, session = nil) ⇒ Object
Sends a notification to the configured outputs.
- #register(notifier_class) ⇒ Object
Constructor Details
#initialize(settings) ⇒ Notifier
Returns a new instance of Notifier.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rusen/notifier.rb', line 9 def initialize(settings) @settings = settings @notifiers = [] Notifiers.constants.each do |constant| klass = Notifiers.const_get(constant) if @settings.outputs.include?(klass.identification_symbol) register(klass) end end end |
Instance Method Details
#notify(exception, request = nil, environment = nil, session = nil) ⇒ Object
Sends a notification to the configured outputs.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rusen/notifier.rb', line 31 def notify(exception, request = nil, environment = nil, session = nil) begin notification = Notification.new(exception, request, environment, session) @notifiers.each do |notifier| notifier.notify(notification) end # We need to ignore all the exceptions thrown by the notifiers. rescue Exception warn("Rusen: Some or all the notifiers failed to sent the notification.") end end |
#register(notifier_class) ⇒ Object
21 22 23 |
# File 'lib/rusen/notifier.rb', line 21 def register(notifier_class) @notifiers << notifier_class.new(@settings) end |