Re: initialization dependencies

[email protected] (Stevan Little)
Newsgroups perl.moose
Message-ID <[email protected]>
Sean,

On Jan 29, 2009, at 10:59 AM, Sean Allen wrote:
> I'm playing around with Moose in a real world work scenario and came  
> across an interesting question...
>
> I'm working on a series of reports that mostly similar, you have to
>
> build up limits to a general query.
> pull that query
> organize the data
> pull all the data together for display and some math
>
> so you need to get things like:
>
> limits
> value X
> value Y
>
> value X and Y depend on limits to be pulled...
>
> limits is like this:
>
> has 'limits'  => ( is => 'rw', isa => 'Str', builder =>  
> 'build_limits' );
>
> could X and Y also be done with builders when they depend on limits  
> being set?
> is there a way to order the initialization of attributes? do i have  
> to order it?

Yes, any attribute can have a builder on it, but since the other two  
depend on limits, then you will likely want to make valueX and valueY  
attributes lazy. There is a Recipe in the cookbook about lazy and docs  
in Moose.pm as well.

> is moose smart enough to order them correctly ( pie in the sky  
> there )?

Nope, it is smart enough to give you control instead :)

- Stevan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.