Sha256: 75c56123966875622ca64c9fb548a1f201c71ad235e84c68f06c1cb74e83b4b8
Contents?: true
Size: 672 Bytes
Versions: 5
Compression:
Stored size: 672 Bytes
Contents
module Betterlog module Notifiers class_attr_accessor :notifiers self.notifiers = Set[] def self.register(notifier) notifier.respond_to?(:notify) or raise TypeError, "notifier has to respond to notify(message, hash) interface" notifiers << notifier self end def self.notify(event) event.notify? or return notifiers.each do |notifier| context(event.as_json) notifier.notify(event[:message], event.as_json) end end def self.context(data) notifiers.each do |notifier| notifier.respond_to?(:context) or next notifier.context(data) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems