Subject: | method unmodified when consuming a role that consumes a role with a method modifier |
I'm using this module to create a role
that calls 'requires' and 'around' for a method.
When this role is consumed by a class
that defines the desired method
it gets modified as expected.
When this role is consumed by another role
(that defines the desired method)
and that role is consumed by a class
the class gets the *unmodified* method.
I have no idea what's happening, but was able to create a minimal test
case (attached).
Subject: | test_two_roles.pl |
use strict;
use warnings;
use Test::More 0.88;
{
package FooMod;
# works with Moose::Role, but not with this:
use MooseX::Role::AttributeOverride;
requires 'foo';
around foo => sub { shift->() . 'bar' };
}
{
package FooBase;
# works with either one:
use Moose::Role;
#use MooseX::Role::AttributeOverride;
with 'FooMod';
sub foo { 'foo' }
}
{
package OneRole;
use Moose;
with 'FooMod';
sub foo { 'one' }
__PACKAGE__->meta->make_immutable;
}
{
package TwoRoles;
use Moose;
with 'FooBase';
__PACKAGE__->meta->make_immutable;
}
is(OneRole->new->foo(), 'onebar', 'class with role');
is(TwoRoles->new->foo(), 'foobar', 'class with role with role');
done_testing;