From: Hugh Sasse Date: 2005-10-20T21:01:45+09:00 Subject: Reflection, observ(er|able) instance vars? I have an object for which equality tests take a long time, and I have lots of others to compare it with. It is an instance variable of my class, and it is also accessble by attr_accessor. I'd like to hold a hash (number not Hash.new()) for this object so I can compare it quickly with another. How do I detect that it has changed so that the hash gets updated correctly? Does attr_accessor construct code that leaves the right hooks in to detect this, or must I write my own? Should attr_accessor do that if it doesn't? Can I trap this by interposing in freeze tests, somehow? If this is a code smell, how should I handle frequently queried, slow-to-test, but changing instance variables? Make them all observables and use update()? (That sounds expensive.) Thank you Hugh