From: Gregory Brown Date: 2007-07-06T07:20:15+09:00 Subject: Re: Calling an arbitrary method as and when an array's contents change On 7/5/07, Dan Stevens (IAmAI) wrote: > I have a collection class that extends the Array class and I wish to > have a particular method to be called whenever the contents of an > instance of the class change. Can anyone advise on how I can achieve > this? > > I'm aware that I can compare #hash with a previous saved value to > determine if the contents of the instance have changed since the last > time #hash was called. Therefore, if I can find a means of calling an > arbitrary method or piece of code every time any method is called on > the instance, I could achieve what I'm after. Can I override > Object#send? It sounds like you might be able to set up something like this with Observer. http://www.ruby-doc.org/stdlib/libdoc/observer/rdoc/index.html