Module: Yap::Shell::EventEmitter
- Defined in:
- lib/yap/shell/event_emitter.rb
Instance Method Summary collapse
Instance Method Details
#_callbacks ⇒ Object
3 4 5 |
# File 'lib/yap/shell/event_emitter.rb', line 3 def _callbacks @_callbacks ||= Hash.new { |h, k| h[k] = [] } end |
#emit(type, *args) ⇒ Object
12 13 14 15 16 |
# File 'lib/yap/shell/event_emitter.rb', line 12 def emit(type, *args) _callbacks[type].each do |blk| blk.call(*args) end end |
#on(type, *args, &blk) ⇒ Object
7 8 9 10 |
# File 'lib/yap/shell/event_emitter.rb', line 7 def on(type, *args, &blk) _callbacks[type] << blk self end |