Class: Redwood::UpdateManager
- Includes:
- Singleton
- Defined in:
- lib/sup/update.rb
Overview
Classic listener/broadcaster paradigm. Handles communication between various parts of Sup.
Usage note: don’t pass threads around. Neither thread nor message equality is defined anywhere in Sup beyond standard object equality. To communicate something about a particular thread, just pass a representative message from it around.
(This assumes that no message will be a part of more than one thread within a single “view”. Luckily, that’s true.)
Instance Method Summary collapse
-
#initialize ⇒ UpdateManager
constructor
A new instance of UpdateManager.
- #register(o) ⇒ Object
- #relay(sender, type, *args) ⇒ Object
- #unregister(o) ⇒ Object
Methods included from Singleton
Constructor Details
#initialize ⇒ UpdateManager
Returns a new instance of UpdateManager.
17 18 19 |
# File 'lib/sup/update.rb', line 17 def initialize @targets = {} end |
Instance Method Details
#register(o) ⇒ Object
21 |
# File 'lib/sup/update.rb', line 21 def register o; @targets[o] = true; end |
#relay(sender, type, *args) ⇒ Object
24 25 26 27 |
# File 'lib/sup/update.rb', line 24 def relay sender, type, *args meth = "handle_#{type}_update".intern @targets.keys.each { |o| o.send meth, sender, *args unless o == sender if o.respond_to? meth } end |
#unregister(o) ⇒ Object
22 |
# File 'lib/sup/update.rb', line 22 def unregister o; @targets.delete o; end |