All,

Not sure if this is addressed in some way with the merge of MXAH to core, but I ran into a small issue with roles and aliasing methods. Not sure if I'm approaching this right though, so please let me know if I'm not. I already have the workaround (e.g. explicitly define the methods in the role, don't use 'provides'). This was using Moose 0.89 on OS X 10.6 (works great on Snow Leopard BTW).

chris

================================

use Test::More qw(no_plan);

{
    package MyRole;
    use Moose::Role;
    use MooseX::AttributeHelpers;

    has 'list'  => (
        is          => 'ro',
        isa         => 'ArrayRef[Obj]',
        default     => sub {[]},
        lazy        => 1,
        metaclass   => 'Collection::Array',
        provides    => {
            'push'      => 'add_stuff',
            'elements'  => 'get_stuff',
            'clear'     => 'delete_stuff',
            'count'     => 'num_things',
        }
    );

    no Moose::Role;
}

{
    package MyClass;

    use Moose;

    with 'MyRole' => {
        alias   => {
            'add_stuff'     => 'add_my_stuff'
        },
        excludes    => 'add_stuff'
    };
}

# Should be: first test fails, second passes
can_ok('MyClass', 'add_stuff');     # passes
can_ok('MyClass', 'add_my_stuff');  # fails

my $inst = MyClass->new();

can_ok($inst, 'add_stuff');    # passes
can_ok($inst, 'add_my_stuff'); # fails


Reply via email to