From: Paul Murton <34993@...> Date: 2006-08-28T06:37:50+09:00 Subject: Re: Detecting when an object's instance variables are modifi unknown wrote: > Hi -- > > On Mon, 28 Aug 2006, David Vallner wrote: > >> monitor setters. Would probably be horribly, terribly slow. >> >> It's probably best to have your objects trace changes by design. Modify the >> Object class to have a #dirty? and #clean! method, and alias / redefine the >> #attr_writer method to generate methods that will set the dirty flag when >> used? > > I was thinking of something similar, but using Observable -- but the > problem is that it would only work for instance variable changes that > go through attr_writer. > > > David I appreciate all of the help so far. I had considered the possibility of redefining attr_writer, but had hoped there might be a way of doing this so that it would work for changes that DON'T go through attr_writer. In fact this is actually quite important to me, because I am interested in changes to ANY instance variable (including if a previously non-existant instance variable is set), not just those made externally accessible with a writer method. I should have been more clear about this in my original post. I've been thinking about this for ages now and my current thoughts are that there may not be any way of getting quite what I want here :/ Any further suggestions appreciated -- Posted via http://www.ruby-forum.com/.