|
|
| Just another Perl shrine | |
| PerlMonks |
Making 'all' the attributes read only by default (Moo)by blindluke (Hermit) |
| on Jan 22, 2015 at 21:34 UTC ( [id://1114189]=perlquestion: print w/replies, xml ) | Need Help?? |
|
blindluke has asked for the wisdom of the Perl Monks concerning the following question: Is there a good way of making all the object attributes readonly in Moo? Something that would allow me to replace:
With something like:
There is an interesting blog post by mascip, about the possibility of enabling immutability for all the objects of a given class. The post refers to Moose, and its author seems to ask about a stronger restriction - making the object truly immutable. I'm only looking for some way to make the is => 'ro' a default for all the attributes of a given class. Still, I wanted to link this post here since it provides a good explanation for the reasoning behind my question. One 'bad way' I can think of would be using Filter::Simple, but I hope to find another way to do it. Humbly seeking your advice. - Luke
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||