From: firstname@... (Hans Fugal) Date: 2003-12-16T01:06:59+09:00 Subject: Re: Subclassing Array With a slight modification what you offered would work: class SimilArray def initialize(ary) @ary=ary end include Notifier def method_missing(:method,*args,&blk) @ary.send(:method,*args,&blk) notify # this is what's different end end But it would always notify even on read-only operations, and so it's wasteful. But I could check by name for writing operations. Another approach would be a mixin that provides the Array operations based on [], []=, and <=> (for example). Is there such a beast? Maybe I should just use Enumerable and to_a? > BTW, do you know that an observer module already exist in the standard > ruby lib ? Yeah, but it is callback-based, but I would like mine to be proc-based. e.g. Observable way: class MyObservable include Observable attr_reader :foo def foo=(o) @foo = o changed notify_observers(self) end end class MyObserver def initialize MyObservable.new.add_observer(self) def update(o) puts o.foo end end Notifier way: class MyObservable include Notifier attr_reader ;foo def foo=(o) @foo = o notify end end class MyObserver def initialize o = MyObservable.new bar = "bar" o.add_notification { puts "#{o.foo} #{bar}" } end end My Notifier module is based on http://www.rubygarden.org/ruby?ObserverPattern -- Hans Fugal | De gustibus non disputandum est. http://hans.fugal.net/ | Debian, vim, mutt, ruby, text, gpg http://gdmxml.fugal.net/ | WindowMaker, gaim, UTF-8, RISC, JS Bach --------------------------------------------------------------------- GnuPG Fingerprint: 6940 87C5 6610 567F 1E95 CB5E FC98 E8CD E0AA D460