I have a Moose class with an attribute lazy_build. The value of this attribute is a function of another (nonslide) attribute.
Suppose someone creates an instance of a class with a value of 42 for the required attribute. Then they request a lazy attribute, which is calculated as a function of 42. Then they have a nerve to change the first attribute!
The lazy one has already been created, so the builder will not be called again, and the lazy attribute is now out of date.
I have a solution now that I support the dirty flag of the required attribute, and the accessory on the lazy one checks the dirty flag and restores it if necessary.
However, this seems like a lot of work. Is there a way to handle this in Moose, for example. using traits?
source
share