in reply to Re: Simple Mouse/Moose question
in thread Simple Mouse/Moose question
>>Pretty much any time you want the builder/default of one attribute to have access to the values of another attribute, you want to use lazy. The order of attribute initialization in Moose (and Mouse) is undefined (basically hash-order).
Okay, but that is not what is going on in my example. There is only one builder method; the second method is called via the modifier "after" which guarantees do_n() already happened. Ie, do_n2() is only called "after" do_n().
The problem does not matter much since there are other ways to accomplish the goal (eg, assigning do_n2() as a lazy builder method works). It just makes me suspicious of the use value of the Moose style method modifiers: if I assign an "after" method but changes made to the object in the triggering function have not take place when its "after" method is called, does that not make using such a method modifier very problematic???? Eg, from Moose::Manual::MethodModifiers:
Similarly, an after modifier could be used for logging an action that was taken.
I guess it could be used, but let's say the action taken was that a string value was changed, and I call an after modifier method to record the change -- BUT the value is still the same as it was prior to to the action that "was" taken, then how can this modifier method log the change correctly?? It will record the previous value, not the new one, since the object it receives does not reflect assignments made in the method it "modifies after".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Simple Mouse/Moose question
by stvn (Monsignor) on Feb 24, 2011 at 15:50 UTC | |
|
Re^3: Simple Mouse/Moose question
by ikegami (Patriarch) on Feb 24, 2011 at 16:02 UTC |