module Jackal::Utils::Events

Event generation helper

Public Instance Methods

event!(type, data=Smash.new) click to toggle source

Send event

@param type [String, Symbol] event type @param data [Smash] optional data @return [NilClass]

# File lib/jackal/utils/events.rb, line 13
def event!(type, data=Smash.new)
  event_source = Carnivore::Supervisor.supervisor[:events]
  if(event_source)
    payload = new_payload(
      :event, :event => Smash.new(
        :type => type,
        :stamp => Time.now.to_f,
        :data => data
      )
    )
    debug "Sending event data - type: #{type} ID: #{payload[:id]} data: #{data.inspect}"
    event_source.transmit(payload)
  end
end