Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Moose and BUILD and 'ro' attributes

by stvn (Monsignor)
on Dec 15, 2010 at 15:44 UTC ( #877292=note: print w/ replies, xml ) Need Help??


in reply to Moose and BUILD and 'ro' attributes

How do I set read-only variables in BUILD?

Why not just make a private writer, like this

has 'foo' => ( is => 'ro', isa => 'Something', writer => '_set_foo', lazy => 1, build => '_build_foo', );

Which is called first, BUILD or the attribute_builders?

The entire object instance is created and finalized before BUILD is called. When it gets to BUILD you can be sure you have a complete object (minus any non-initialized lazy attrs, etc).

-stvn

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://877292]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2016-07-28 19:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What is your favorite alternate name for a (specific) keyboard key?


















    Results (257 votes). Check out past polls.