You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stacking roles (using roles within roles) doesn't seem to work when attributes are required, even when the 'with' keyword is used after attributes are declared. See the Biome::Role::Location::Does_* classes (interfaces), the Biome::Role::Location::Simple_/Split classes (their role interfaces), and Biome::Location::_ (the classes).
This does work when combining roles in a base class, however, which is a workaround though a bit tedious, as it involves repeatedly adding the same lines every time in cases where the implemention and interface roles are both needed.
This does work with Moose, however, so I need to whittle this down to a small test case.
The text was updated successfully, but these errors were encountered:
I traced the problem to this. Roles consuming roles can't define attributes; this is a well-known problem in Moose that isn't easy to fix. It has been TODO'd for now.
The below code will blow up when combined into the class b/c MyRole1 and myRole2 are both consumed into RoleTest at the same time; MyRole1 isn't consumed into MyRole2 first prior to consuming into RoleTest.
{
package MyRole1;
use Biome::Role;
requires 'foo', 'bar','att1', 'att2';
no Biome::Role;
}
###############################
{
# import Moose magic through meta class (no need to import separately)
package MyRole2;
use Biome::Role;
with 'MyRole1';
requires 'bah';
has 'att1' => (isa => 'Str', is => 'rw');
sub foo { 1 }
no Biome::Role;
}
###############################
{
package RoleTest;
use Biome;
has 'att2' => (isa => 'Int', is => 'rw');
with 'MyRole2';
sub bar { 2 }
sub baz { 42 };
sub bah {98.6 };
no Biome;
}
Stacking roles (using roles within roles) doesn't seem to work when attributes are required, even when the 'with' keyword is used after attributes are declared. See the Biome::Role::Location::Does_* classes (interfaces), the Biome::Role::Location::Simple_/Split classes (their role interfaces), and Biome::Location::_ (the classes).
This does work when combining roles in a base class, however, which is a workaround though a bit tedious, as it involves repeatedly adding the same lines every time in cases where the implemention and interface roles are both needed.
This does work with Moose, however, so I need to whittle this down to a small test case.
The text was updated successfully, but these errors were encountered: