in reply to Re^2: Moose object construction
in thread Moose object construction
What you want to do is change your visitor attribute to be something like:
Then inside your BUILD method, you will want to do:has 'visitors' => ( is => 'ro', writer => '_set_visitors', init_arg => undef, );
The init_arg being set to "undef" will ensure that no one can do:$self->_set_visitors( ... );
But all this said, you should really spend some time reading the Moose::Manual. Several of the mistakes you have made seem to be caused by the fact you are guessing and/or making assumptions of your own about how Moose works, rather then actually taking the time to learn how it actually works. You also might find some of the presentations on http://moose.perl.org helpful as well, there are several excellent introductory ones from recent conferences.MyClass->new( visitors => ... )
You really too should give a look to MooseX::SimpleConfig as it solves this problem for you and the code has been battle tested already.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Moose object construction
by thargas (Deacon) on Feb 10, 2011 at 17:17 UTC | |
by stvn (Monsignor) on Feb 11, 2011 at 00:47 UTC | |
by saintex (Scribe) on Feb 11, 2011 at 15:13 UTC |