![]() |
|
Perl-Sensitive Sunglasses | |
PerlMonks |
comment on |
( #3333=superdoc: print w/replies, xml ) | Need Help?? |
As derby said, $self will only be populated with keys corresponding to any attributes which have beeen defined for the class (including those defined in any roles the class does). You could define your role like this:
More importantly, you're making the mistake of treating $self like it's a hashref. It's not. (Actually it is by default, but you're supposed to pretend it's not. Let's pretend it's not...) Because it's not a hashref, keys %$self is meaningless. Instead you should access attributes via the accessors Moose generates:
Lastly, have you noticed that BUILD gets passed not one argument, but two?
use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
In reply to Re: Moose::Role not getting params passed via ->new()
by tobyink
|
|