Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^4: Passing arrayref to Moose attributes

by tobyink (Abbot)
on Apr 21, 2013 at 08:16 UTC ( #1029736=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Passing arrayref to Moose attributes
in thread Passing arrayref to Moo attributes

Under Moose you need to add traits => ["Array"] to the attribute declaration. See Moose::Meta::Attribute::Native::Trait::Array.

With Moo you'd use handles_via => "Array" but you'd need to install MooX::HandlesVia first.

package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name


Comment on Re^4: Passing arrayref to Moose attributes
Select or Download Code
Replies are listed 'Best First'.
Re^5: Passing arrayref to Moose attributes
by davido (Archbishop) on Apr 21, 2013 at 14:14 UTC

    Thanks! :)


    Dave

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (17)
As of 2015-07-29 14:08 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 (263 votes), past polls