Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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


Comment on Re: Moose and BUILD and 'ro' attributes
Download Code

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 chanting in the Monastery: (9)
As of 2014-08-01 06:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (257 votes), past polls