------art_39948_20425781.1148752039946
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hello:

I am using the observer pattern that comes with the standard Ruby
distribution and found that the publisher allows the same observer
to be 'added' more than once.

code from observer.rb

  def add_observer(observer)
    @observer_peers = [] unless defined? @observer_peers
    unless observer.respond_to? :update
      raise NoMethodError, "observer needs to respond to `update'"
    end
    @observer_peers.push observer
  end

I was wondering if it would make sense to change the last but one
line in method 'add_observer' to

@observer_peers.push observer      if not @observer_peers.include?(observer)


In other words, am I missing an obvious reason for a publisher to
allow an observer to register more than once?

Thanks,
Madan.

------art_39948_20425781.1148752039946--