Sha256: 522069c58c4480f251441f13d378314c0a06582e318ebb9317ff52fccdd824b9

Contents?: true

Size: 640 Bytes

Versions: 7

Compression:

Stored size: 640 Bytes

Contents

require 'json'

module EventBus
  # Public: An class which decorates el-rabbit topic creation.
  #
  class Emitter
    # Public: Produces a event on the Broker.
    #
    # event - The event to be produced.
    #
    # Returns the Event.
    def self.trigger(*events)
      events.flatten.each_with_index do |event, index|
        raise MissingAttributeError.new("Event on position #{index} must have a body") unless event.has_body?
        raise MissingAttributeError.new("Event on position #{index} must have a name") unless event.has_name?
      end

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

      events
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
event_bus_rb-2.1.0 lib/event_bus/emitter.rb
event_bus_rb-2.0.3 lib/event_bus/emitter.rb
event_bus_rb-2.0.2 lib/event_bus/emitter.rb
event_bus_rb-2.0.1 lib/event_bus/emitter.rb
event_bus_rb-2.0.0 lib/event_bus/emitter.rb
event_bus_rb-1.1.0 lib/event_bus/emitter.rb
event_bus_rb-1.0.1 lib/event_bus/emitter.rb