From: Trans Date: 2006-11-09T03:55:13+09:00 Subject: Re: Proc as Observer Tim Pease wrote: > Working with an Observable object, I wanted to be able to add a Proc > as an observer. Observable requires all observers to implement an > update method. When the Observable state changes, this is the method > that will be called to notify observers of the state change. Interesting... I'd like to see a simple example of this. > My generic solution was to create a module that adds an update method > for Proc objects. > > module ProcAsObserver > def update( *args ) > self.call *args > end > end > > To use this module ... > > method = lambda {|*args| args.each {|x| puts x}} > method.extend ProcAsObserver > > my_observable_object.add_observer(method) > > That's it! Just a handy little tip for anyone working with Observable objects. Given your approach I think I'd just go ahead and do: class Proc alias :update :call end T.