Sha256: d94bd460796b8f63c692fe5b7ccc46bb57025f63416a3d995f28cfa1db3eef29

Contents?: true

Size: 619 Bytes

Versions: 17

Compression:

Stored size: 619 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)
      notifiers.each do |notifier|
        notifier.notify(event.notify?, event.as_json)
      end
    end

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

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
betterlog-1.1.1 lib/betterlog/notifiers.rb
betterlog-1.1.0 lib/betterlog/notifiers.rb
betterlog-1.0.0 lib/betterlog/notifiers.rb
betterlog-0.20.3 lib/betterlog/notifiers.rb
betterlog-0.20.2 lib/betterlog/notifiers.rb
betterlog-0.20.1 lib/betterlog/notifiers.rb
betterlog-0.20.0 lib/betterlog/notifiers.rb
betterlog-0.19.0 lib/betterlog/notifiers.rb
betterlog-0.18.0 lib/betterlog/notifiers.rb
betterlog-0.15.2 lib/betterlog/notifiers.rb
betterlog-0.15.1 lib/betterlog/notifiers.rb
betterlog-0.15.0 lib/betterlog/notifiers.rb
betterlog-0.14.1 lib/betterlog/notifiers.rb
betterlog-0.14.0 lib/betterlog/notifiers.rb
betterlog-0.13.1 lib/betterlog/notifiers.rb
betterlog-0.13.0 lib/betterlog/notifiers.rb
betterlog-0.12.2 lib/betterlog/notifiers.rb