Class: Hallmonitor::Dispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/hallmonitor/dispatcher.rb

Class Method Summary collapse

Class Method Details

.add_outputter(outputter) ⇒ Object

Adds an outputter. Outputters are required to respond to :process

Parameters:

  • outputter (Object)

See Also:



14
15
16
# File 'lib/hallmonitor/dispatcher.rb', line 14

def self.add_outputter(outputter)
  @outputters << outputter if outputter.respond_to?(:process)
end

.clear_outputtersObject

Removes all outputters



19
20
21
# File 'lib/hallmonitor/dispatcher.rb', line 19

def self.clear_outputters
  @outputters = []
end

.output(event) ⇒ Object

Outputs an event via each registered outputter. If Configuration has the option ‘trap_outputter_exceptions` set to `true` then this method will trap and squash any errors raised by the outputter.

Parameters:

  • event (Event)

    The event to output

Returns:

  • nil



29
30
31
32
33
34
35
36
37
38
# File 'lib/hallmonitor/dispatcher.rb', line 29

def self.output(event)
  @outputters.each do |o|
    begin
      o.process(event)
    rescue
      raise unless Hallmonitor.config && Hallmonitor.config.trap_outputter_exceptions
    end
  end
  nil
end

.outputtersArray<Outputter>

Returns list of outputters registered

Returns:



7
8
9
# File 'lib/hallmonitor/dispatcher.rb', line 7

def self.outputters
  @outputters
end