Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 pondering the Monastery: (5)
As of 2015-07-08 01:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls