Module: Betterlog::Notifiers

Defined in:
lib/betterlog/notifiers.rb

Class Method Summary collapse

Class Method Details

.context(data_hash) ⇒ Object



21
22
23
24
25
26
# File 'lib/betterlog/notifiers.rb', line 21

def self.context(data_hash)
  notifiers.each do |notifier|
    notifier.respond_to?(:context) or next
    notifier.context(data_hash)
  end
end

.notify(event) ⇒ Object



15
16
17
18
19
# File 'lib/betterlog/notifiers.rb', line 15

def self.notify(event)
  notifiers.each do |notifier|
    notifier.notify(event.notify?, event.as_hash)
  end
end

.register(notifier) ⇒ Object



8
9
10
11
12
13
# File 'lib/betterlog/notifiers.rb', line 8

def self.register(notifier)
  notifier.respond_to?(:notify) or raise TypeError,
    "notifier has to respond to notify(message, hash) interface"
  notifiers << notifier
  self
end