make_immutable() does two things, object construction and destruction are effectively "inlined" in your class, and no longer invokes the meta API...
And no Moose remove the Moose helper functions like has(), before() and the others so they will not be in the object after object creation.... Charles de Gaulle - "The better I get to know men, the more I find myself loving dogs." - http://www.brainyquote.com/quotes/authors/c/charles_de_gaulle.html On Mon, Dec 21, 2009 at 3:37 PM, Will Willis <[email protected]> wrote: > Thanks Todd, > > What does the immutable bit do at the end? Freeze my object to any further > changes? What about 'no Moose'? > > I've seen it done in the manual but haven't seen an explaination. > > On Dec 21, 2009 10:25 AM, "Todd Rinaldo" <[email protected]> wrote: > > I'm a big fan of lazy. You're kinda randomly initializing your object > in the object if you don't use it. Oh and per the Moose gods, don't > forget to turn off Moose and make immutable at the end of your module. > > Try this: > > #!/usr/bin/perl use strict; use Website; my $web = Website->new(name > ='Google', url ='http://www.g... > > package Website; use Moose; use WWW::Mechanize; > > # Mech will initialize whenever it's first called. > has '_mech' => (isa => 'Object', is => 'ro', lazy => 1, default => > sub { WWW::Mechanize->new }); > > has 'name' =( is ='rw', isa ='Str', required =1); has 'url' =(is ='rw', > isa ='Str', required =1)... > > $self->_mech->get($self->url); return $self->_mech->content; } > > no Moose; > __PACKAGE__->meta->make_immutable; > 1; > > _______________________________________________ Houston mailing list > [email protected] http://mail.pm.o... > > _______________________________________________ > Houston mailing list > [email protected] > http://mail.pm.org/mailman/listinfo/houston > Website: http://houston.pm.org/ > _______________________________________________ Houston mailing list [email protected] http://mail.pm.org/mailman/listinfo/houston Website: http://houston.pm.org/
