Class: Faulty::Events::FilterNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/faulty/events/filter_notifier.rb

Overview

Wraps a Notifier and filters events by name

Instance Method Summary collapse

Constructor Details

#initialize(notifier, events: nil, exclude: nil) ⇒ FilterNotifier



12
13
14
15
16
# File 'lib/faulty/events/filter_notifier.rb', line 12

def initialize(notifier, events: nil, exclude: nil)
  @notifier = notifier
  @events = Set.new(events || EVENTS)
  exclude&.each { |e| @events.delete(e) }
end

Instance Method Details

#notify(event, payload) ⇒ Object

Notify all listeners of an event

If a listener raises an error while handling an event, that error will be captured and written to STDERR.



24
25
26
27
28
# File 'lib/faulty/events/filter_notifier.rb', line 24

def notify(event, payload)
  return unless @events.include?(event)

  @notifier.notify(event, payload)
end