Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: Passing arrayref to Moose attributes

by davido (Archbishop)
on Apr 21, 2013 at 04:11 UTC ( #1029701=note: print w/replies, xml ) Need Help??


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

I don't think that's a Moo/Moose-compatibility issue (I could be wrong, and if so, would like additional clarification). It would be equally problematic with Moose, wouldn't it? At least after converting it to Moose by quoting the isa component, I get:

Cannot delegate my_array to elements because the value of maze_map is +not an object (got 'ARRAY(0x163b880)') at...

...which seems to be the same type of error produced under Moo, with a slightly different message.

But I suppose I should be asking for clarification. Should that work under Moose?


Dave

Replies are listed 'Best First'.
Re^4: Passing arrayref to Moose attributes
by tobyink (Abbot) on Apr 21, 2013 at 08:16 UTC

    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

      Thanks! :)


      Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1029701]
help
Chatterbox?
[choroba]: 10 bugs in the tracker?
[1nickt]: Yes, and recommendation against using it, in the doc for Devel::Declare, on whcih it is based.
[1nickt]: I asked the new $boiss what I should brush up on before starting work next week, and he named Moo, DBIx::Class and Method::Signatures
[1nickt]: choroba That's why I asked if anyone is using it :-)
choroba only has used Moo from the htree
[1nickt]: Pardonm?

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2017-11-24 13:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (349 votes). Check out past polls.

    Notices?