From: Jason Voegele Date: 2003-02-10T08:02:13+09:00 Subject: Trapping Access/Modification of Objects After a long delay, I'm now starting to work on the RubyGOODS library again. This library is intended to provide an interface to the GOODS OO database, as well as serve as a more generic object persistence library (eventually including an object-relational mapping layer). What I'm actually working on now is an API based on the ODMG's Object Data Standard 3.0. To support this API, I need to be able to track, in a generic fashion, when objects are accessed and modified. This job would be simpler if I could simply wait until the end of a transaction and compare live objects to snapshots of those objects as they existed at the beginning of the transaction. Unfortunately, I need to obtain a lock on an object PRIOR TO the access or modification. I'm using proxy objects and AspectR to handle some of this functionality, so I am able to trap all accesses to any persistent object. However, I haven't been able to think of any way to determine if the object is about to be modified. The closest I can come is to rely on the conventions of modifier methods ending in '=' or '!'. But this is not 100% reliable, considering methods such as Array#delete. The only other way I can think of is to have users of the library call some method to explicitly indicate that an object is about to be modified, but I'd prefer a more transparent solution. Does anyone have any thoughts? Thanks. -- Jason Voegele "There is an essential core at the center of each man and woman that remains unaltered no matter how life's externals may be transformed or recombined. But it's smaller than we think." -- Gene Wolfe, The Book of the Long Sun