Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
However, trying to extend a Moo::Role gives the error "Can't extend role" (see also https://github.com/moose/Moo/blob/master/t/extends-role.t). Is there a nice way to handle this situation?package BasicRole; use Moo::Role; has 'attrib' => ( is => 'ro' ); sub do_something { ... } 1; package NotSoBasicRole; use Moo; extends 'BasicRole'; has '+attrib' => ( default => sub { return 1; } ); 1; package SpecialRole; use Moo; extends 'NotSoBasicRole; has '+attrib' => ( default => sub { return 2; } ); sub do_something_else { ... } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Moo role subclassing
by Arunbear (Prior) on Feb 24, 2016 at 18:38 UTC | |
by Anonymous Monk on Feb 26, 2016 at 00:12 UTC | |
|
Re: Moo role subclassing
by arkturuz (Curate) on Feb 24, 2016 at 17:05 UTC | |
by Anonymous Monk on Feb 24, 2016 at 17:28 UTC | |
by Laurent_R (Canon) on Feb 24, 2016 at 17:52 UTC |