"be consistent" | |
PerlMonks |
Moose: Adding methods to a class via attribute traitsby Nasrudin (Acolyte) |
on Jan 16, 2012 at 23:55 UTC ( [id://948231]=perlquestion: print w/replies, xml ) | Need Help?? |
Nasrudin has asked for the wisdom of the Perl Monks concerning the following question: Greetings. Apologies if this has been asked before or is easily found by searching (I've tried, honest). I'm using Moose and trying to apply a trait to an attribute which automatically adds a method into the containing class. I've done this successfully but I'm thinking there's a better way here, and I'd appreciate any feedback provided. Thanks in advance.
UPDATE: Perusing the way that the deprecated MooseX::AttributeHelpers worked led me to understand Tobyink's comment below. Here is a cleaner solution, involving just the role:
Thanks again for the insight! UPDATE2: Made the idea a bit clearer, no need to loop the attributes since $self is apparently an attribute class
Back to
Seekers of Perl Wisdom
|
|