Class: Cross::Talk::Manager
- Inherits:
-
Object
- Object
- Cross::Talk::Manager
- Includes:
- Celluloid, Celluloid::Logger
- Defined in:
- lib/cross-talk/manager.rb
Instance Method Summary collapse
-
#initialize ⇒ Manager
constructor
A new instance of Manager.
- #notify(event, sender) ⇒ Object
- #register(event, receiver) ⇒ Object
Constructor Details
#initialize ⇒ Manager
Returns a new instance of Manager.
7 8 9 |
# File 'lib/cross-talk/manager.rb', line 7 def initialize @event_table = {} end |
Instance Method Details
#notify(event, sender) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/cross-talk/manager.rb', line 11 def notify(event, sender) receivers_for(event).each do |receiver| next unless receiver.respond_to?(event) if receiver.respond_to?(:async) receiver.async else receiver end.send(event, sender) end end |
#register(event, receiver) ⇒ Object
22 23 24 25 |
# File 'lib/cross-talk/manager.rb', line 22 def register(event, receiver) receivers_for(event) << receiver nil end |