Hi,
For a project I need (slave) attributes that default to the value of
another (master) attribute, and keep following their master's value
until they are set with a value of their own.
At first I tried using lazy attributes with code ref defaults that would
fetch the value of the attribute that is to be tracked. That doesn't
work however, since the value is fetched only on the first get, and
after that stays static even if the master attribute's value changes.
In the end I ended up writing a trait, based on the MooseX::Worm trait
that came by this list a couple of days ago.
It can be found here:
http://gist.github.com/307789
Although it seems to do the job, I have a few questions:
1) Is there a simpler way of doing this? I've searched the docs, CPAN
and google but I couldn't come up with an answer.
2) If not, is the implementation of the trait correct? What bothers me
most is extending the private _inline_get sub, which seems wrong
(although MooseX::Worm does that too).
Martin