in reply to Creating accessors on the fly, or not...
he Moose tutorial says you should try to __PACKAGE__->meta->make_immutable; which my current method doesn't allow me to do...
Yes, because make_immutable makes your class readonly so you can't add methods to it (at least not via the MOP).
You can however make a class mutable again with $class->meta->make_mutable and then make it immutable again after that with $class->meta->make_immutable. Of course there is a performance penalty with this, but it's not nearly as bad as you might think.
And lastly, I would suggest replacing
with the more MOPishhas $accessor => ( is => 'ro' );
$self->meta->add_attribute($accessor, (is => 'ro'));
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Creating accessors on the fly, or not...
by dsheroh (Monsignor) on Jun 13, 2009 at 12:16 UTC | |
by stvn (Monsignor) on Jun 13, 2009 at 18:07 UTC | |
by dsheroh (Monsignor) on Jun 14, 2009 at 10:30 UTC | |
|
Re^2: Creating accessors on the fly, or not...
by lodin (Hermit) on Jun 14, 2009 at 07:14 UTC | |
by stvn (Monsignor) on Jun 15, 2009 at 00:39 UTC |