Sha256: 2f40107bb45b322163bf91e49f6ce3a94f656fbcb2bb45040759a2292cc7a2d1

Contents?: true

Size: 338 Bytes

Versions: 5

Compression:

Stored size: 338 Bytes

Contents

module Vedeu
  class Events
    def initialize
      @handlers = Hash.new { |h, k| h[k] = [] }
    end

    def on(event, &block)
      handlers[event] << block
    end

    def trigger(event, *args)
      handlers[event].each do |handler|
        handler.call(*args)
      end
    end

    private

    attr_accessor :handlers
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vedeu-0.0.30 lib/vedeu/support/events.rb
vedeu-0.0.29 lib/vedeu/support/events.rb
vedeu-0.0.28 lib/vedeu/support/events.rb
vedeu-0.0.27 lib/vedeu/support/events.rb
vedeu-0.0.26 lib/vedeu/support/events.rb