Sha256: dba6d02905b42b6aadc2d902bcd1ad4453ad6facd9c4e92f492f32ea36ca140c

Contents?: true

Size: 432 Bytes

Versions: 2

Compression:

Stored size: 432 Bytes

Contents

module Rocketman
  class Event
    def initialize(event, payload)
      @event = event
      @payload = payload
      Rocketman::Registry.register_event(event)
    end

    def notify_consumers
      consumers = Rocketman::Registry.get_consumers_for(@event)

      return if consumers.nil? || consumers.empty?

      consumers.each do |consumer, action|
        consumer.instance_exec(@payload, &action)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rocketman-0.3.0 lib/rocketman/event.rb
rocketman-0.2.0 lib/rocketman/event.rb