From: Edward Faulkner Date: 2005-10-21T00:14:05+09:00 Subject: Re: Reflection, observ(er|able) instance vars? --BOKacYhQ+x31HxR3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Oct 20, 2005 at 09:01:45PM +0900, Hugh Sasse wrote: > 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? I think the simplest solution it to define your own attribute writer and always use it: class Test attr_reader :my_attribute def my_attribute=(val) @my_attribute = val @my_attribute_hash = make_hash(val) end def some_other_method # Do this my_attribute = something_new # Not this! @my_attribute = something_else end end regards, Ed --BOKacYhQ+x31HxR3 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFDV7OunhUz11p9MSARAp3FAJ0W2bu0HfRIOHl+b1zkV9Za3wqx1gCeL3CX 0Qzu9Cb8TOi8U9e1Yo9KkSY= =Aseo -----END PGP SIGNATURE----- --BOKacYhQ+x31HxR3--