Sha256: 80805a552d68c0625f8913deab1fc0eeac26b8449cc44fd69c15c3fd20f6c273

Contents?: true

Size: 849 Bytes

Versions: 21

Compression:

Stored size: 849 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 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

21 entries across 21 versions & 1 rubygems

Version Path
sup-0.16.0 lib/sup/update.rb
sup-0.15.4 lib/sup/update.rb
sup-0.15.3 lib/sup/update.rb
sup-0.15.2 lib/sup/update.rb
sup-0.15.1 lib/sup/update.rb
sup-0.15.0 lib/sup/update.rb
sup-0.14.1.1 lib/sup/update.rb
sup-0.13.2.1 lib/sup/update.rb
sup-0.14.1 lib/sup/update.rb
sup-0.14.0 lib/sup/update.rb
sup-0.13.2 lib/sup/update.rb
sup-0.13.1 lib/sup/update.rb
sup-0.13.0 lib/sup/update.rb
sup-0.12.1 lib/sup/update.rb
sup-0.12 lib/sup/update.rb
sup-0.11 lib/sup/update.rb
sup-0.10.2 lib/sup/update.rb
sup-0.10.1 lib/sup/update.rb
sup-0.10 lib/sup/update.rb
sup-0.9.1 lib/sup/update.rb