Module: EventMachine::Hiredis::EventEmitter
- Included in:
- BaseClient, Connection
- Defined in:
- lib/em-hiredis/event_emitter.rb
Instance Method Summary collapse
- #emit(event, *args) ⇒ Object
- #listeners(event) ⇒ Object
- #on(event, &listener) ⇒ Object
- #remove_all_listeners(event) ⇒ Object
- #remove_listener(event, &listener) ⇒ Object
Instance Method Details
#emit(event, *args) ⇒ Object
7 8 9 |
# File 'lib/em-hiredis/event_emitter.rb', line 7 def emit(event, *args) _listeners[event].each { |l| l.call(*args) } end |
#listeners(event) ⇒ Object
19 20 21 |
# File 'lib/em-hiredis/event_emitter.rb', line 19 def listeners(event) _listeners[event] end |
#on(event, &listener) ⇒ Object
3 4 5 |
# File 'lib/em-hiredis/event_emitter.rb', line 3 def on(event, &listener) _listeners[event] << listener end |
#remove_all_listeners(event) ⇒ Object
15 16 17 |
# File 'lib/em-hiredis/event_emitter.rb', line 15 def remove_all_listeners(event) _listeners.delete(event) end |
#remove_listener(event, &listener) ⇒ Object
11 12 13 |
# File 'lib/em-hiredis/event_emitter.rb', line 11 def remove_listener(event, &listener) _listeners[event].delete(listener) end |