Class: Anomonitor::Notifiers::Callable
- Inherits:
-
Object
- Object
- Anomonitor::Notifiers::Callable
- Defined in:
- lib/anomonitor/notifiers/callable.rb
Instance Method Summary collapse
- #deliver(anomaly, event: DETECTED) ⇒ Object
-
#initialize(callable) ⇒ Callable
constructor
A new instance of Callable.
Constructor Details
#initialize(callable) ⇒ Callable
Returns a new instance of Callable.
6 7 8 |
# File 'lib/anomonitor/notifiers/callable.rb', line 6 def initialize(callable) @callable = callable end |
Instance Method Details
#deliver(anomaly, event: DETECTED) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/anomonitor/notifiers/callable.rb', line 10 def deliver(anomaly, event: DETECTED) result = if accepts_event_kw? @callable.call(anomaly, event: event.to_s) else @callable.call(anomaly) end normalize_result(result) rescue StandardError => e Anomonitor.logger.warn("[Anomonitor] Custom notifier error: #{e.}") false end |