Sha256: 49f99560e6a8a21a3bdb828ed2da680cd36dc43ec99f3b164020d76e8439df04
Contents?: true
Size: 775 Bytes
Versions: 1
Compression:
Stored size: 775 Bytes
Contents
require_relative '../support/terminal' module Vedeu class Trigger def self.event(event, *args) EventRepository.trigger(event, *args) end end class Register def self.event(event, *args) EventRepository.register(event, &block) end end module EventRepository extend self def handlers @handlers ||= Hash.new { |h, k| h[k] = [] }.merge(defaults) end def register(event, &block) handlers[event] << block end def trigger(event, *args) handlers[event].each do |handler| handler.call(*args) end end private def defaults { :_exit_ => [ proc { fail StopIteration } ], :_mode_switch_ => [ proc { fail ModeSwitch } ] } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.0.35 | lib/vedeu/repository/event_repository.rb |