H
Hugh Sasse
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
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