Module: ErrorNotifier
- Defined in:
- lib/error_notifier.rb,
lib/error_notifier/version.rb
Overview
Error Notifier
Central points for all of your Error notification
Defined Under Namespace
Classes: InvalidNotiferError, Version
Constant Summary
Class Method Summary collapse
-
.add_notifier(name, &block) ⇒ nil
Add a notifier to the list of registed notifications.
-
.delete_notifier(name) ⇒ Notifer
Deletes a notifier from the registered notification tools.
-
.notify(e, options = {}) ⇒ nil
Actually send out the notifications to all the registered services.
Class Method Details
.add_notifier(name, &block) ⇒ nil
Add a notifier to the list of registed notifications
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/error_notifier.rb', line 61 def add_notifier(name, &block) @notifiers = {} unless defined? @notifiers if block_given? @notifiers[name] = block else unless (name.respond_to? :call) && (name.method(:call).arity == 2) raise InvalidNotiferError "When passing object #{name} to the ErrorNotifier, it must respond to `call(e, options)`" end @notifiers[name.class.to_s] = name end end |
.delete_notifier(name) ⇒ Notifer
Deletes a notifier from the registered notification tools
76 77 78 |
# File 'lib/error_notifier.rb', line 76 def delete_notifier(name) @notifiers.delete(name) if defined? @notifiers end |
.notify(e, options = {}) ⇒ nil
Actually send out the notifications to all the registered services
42 43 44 45 46 47 48 |
# File 'lib/error_notifier.rb', line 42 def notify(e, = {}) @notifiers = {} unless defined? @notifiers @notifiers.each do |_name, notifier| notifier.call(e, ) end nil end |