|
|
|
good chemistry is complicated, and a little bit messy -LW |
|
| PerlMonks |
Re: Moose "unions" and inheritanceby tobyink (Prior) |
| on Nov 30, 2012 at 10:27 UTC ( #1006450=note: print w/ replies, xml ) | Need Help?? |
|
Firstly, when overriding an attribute definition in a child class, use:
This allows you to inherit attribute options from the parent class, so you don't need to redeclare, say, is => 'rw' (because the parent class has already declared that). There isn't an especially elegant way of adding to the parent attribute's type constraints. This is the best I could do. I'm using MooseX::Types here because it makes things a little prettier. It's possible to do the same mucking around with Moose::Util::TypeConstraints but who's got the patience?!
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||