Class: EventPeople::Emitter

Inherits:
Object
  • Object
show all
Defined in:
lib/event_people/emitter.rb

Overview

Public: An class which decorates el-rabbit topic creation.

Class Method Summary collapse

Class Method Details

.trigger(*events) ⇒ Object

Public: Produces a event on the Broker.

event - The event to be produced.

Returns the Event.



12
13
14
15
16
17
18
19
20
21
# File 'lib/event_people/emitter.rb', line 12

def self.trigger(*events)
  events.flatten.each_with_index do |event, index|
    raise(MissingAttributeError, "Event on position #{index} must have a body") unless event.body?
    raise(MissingAttributeError, "Event on position #{index} must have a name") unless event.name?
  end

  EventPeople::Config.broker.produce(events.flatten)

  events
end