On 11/8/06, ara.t.howard / noaa.gov <ara.t.howard / noaa.gov> wrote:
>
> in fact, you'd thing add_observer would accept a block and do exactly this.
>

New and improved tip ...


class MyObservableClass
  include Observable

  def add_observer( observer = nil, &block )
    unless block.nil?
      observer = block.to_proc
      class << observer
        alias_method :update, :call
      end
    end
    super observer
  end
end


Now you can do this ...

observable = MyObservableClass.new
proc = observable.add_observer {|*args| puts args.inspect}

observable.delete_observer proc


I'm done posting about this now. Promise!

TwP