Method: Hallmonitor::Monitored#emit

Defined in:
lib/hallmonitor/monitored.rb

#emit(event = nil, tags: {}) {|to_emit| ... } ⇒ Object

Emits an event: self if the event param is nil, the passed in event if it’s an Event, or constructs a Event from the passed in param.

If the parameter is a Event, it will be emitted as is. Otherwise, a new Event will be created with the parameter and emitted.

Parameters:

  • (defaults to: nil)

    The thing to emit, see method description

Yields:

  • (to_emit)

    The thing that’s going to be emitted



72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/hallmonitor/monitored.rb', line 72

def emit(event = nil, tags: {})
  to_emit = self
  unless event.nil?
    to_emit = event.is_a?(Hallmonitor::Event) ? event : Hallmonitor::Event.new(event, tags: tags)
  end

  # If we were given a block, then we want to execute that
  yield(to_emit) if block_given?

  Dispatcher.output(to_emit)
  nil
end