Sha256: 0ffd449bbc196102b01a1ad423ac5af7b3d417a1a947074f2a860b5221e0176b

Contents?: true

Size: 858 Bytes

Versions: 11

Compression:

Stored size: 858 Bytes

Contents

module Redwood

## 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.)

class UpdateManager
  include Redwood::Singleton

  def initialize
    @targets = {}
  end

  def register o; @targets[o] = true; end
  def unregister o; @targets.delete o; end

  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
end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
sup-1.2 lib/sup/update.rb
sup-1.1 lib/sup/update.rb
sup-1.0 lib/sup/update.rb
sup-0.23 lib/sup/update.rb
sup-0.22.1 lib/sup/update.rb
sup-0.22.0 lib/sup/update.rb
sup-0.21.0 lib/sup/update.rb
sup-0.20.0 lib/sup/update.rb
sup-0.19.0 lib/sup/update.rb
sup-0.18.0 lib/sup/update.rb
sup-0.17.0 lib/sup/update.rb