Subject: | Attributes in parameterized roles are not supported |
Looks like MX:SA cannot figure out what to do with attributes added by
parameterized roles -- it sees the attribute get added, but doesn't see
the builder method. Here's a repro case:
{
package Role;
use MooseX::Role::Parameterized;
role {
has attr => (
is => 'ro', isa => 'Str',
lazy_build => 1,
);
method _build_attr => sub { 'foo' };
};
}
{
package Foo;
use Moose;
use MooseX::StrictAttributes;
with 'Role';
}
my $obj = Foo->new;
print $obj->attr, "\n";
This prints:
No _build_attr method defined for attribute attr at
/usr/lib/perl5/site_perl/5.8.8/MooseX/StrictAttributes/Meta/Attribute/Trait/Builder.pm
line 10
MooseX::StrictAttributes::Meta::Attribute::Trait::Builder::__ANON__()
called at
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Moose/Meta/Role/Application.pm
line 72
Moose::Meta::Role::Application::ToClass::apply_attributes('Moose::Meta::Role::Application::ToClass=HASH(0x8fd2194)',
'MooseX::Role::Parameterized::Meta::Role::Parameterized=HASH(0...',
'Moose::Meta::Class=HASH(0x8fc0810)') called at
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Moose/Meta/Role/Application.pm
line 72
Moose::Meta::Role::Application::apply('Moose::Meta::Role::Application::ToClass=HASH(0x8fd2194)',
'MooseX::Role::Parameterized::Meta::Role::Parameterized=HASH(0...',
'Moose::Meta::Class=HASH(0x8fc0810)') called at
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Moose/Meta/Role/Application/ToClass.pm
line 31
Moose::Meta::Role::Application::ToClass::apply('Moose::Meta::Role::Application::ToClass=HASH(0x8fd2194)',
'MooseX::Role::Parameterized::Meta::Role::Parameterized=HASH(0...',
'Moose::Meta::Class=HASH(0x8fc0810)', 'HASH(0x8fcb47c)') called at
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Moose/Meta/Role.pm line
424
Moose::Meta::Role::apply('MooseX::Role::Parameterized::Meta::Role::Parameterized=HASH(0...',
'Moose::Meta::Class=HASH(0x8fc0810)') called at
/usr/lib/perl5/site_perl/5.8.8/MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm
line 121
MooseX::Role::Parameterized::Meta::Role::Parameterizable::apply('MooseX::Role::Parameterized::Meta::Role::Parameterizable=HASH...',
'Moose::Meta::Class=HASH(0x8fc0810)') called at
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Moose/Util.pm
line 132
Moose::Util::_apply_all_roles('Moose::Meta::Class=HASH(0x8fc0810)',
'undef', 'Role') called at
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Moose/Util.pm line 86
Moose::Util::apply_all_roles('Moose::Meta::Class=HASH(0x8fc0810)',
'Role') called at
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Moose.pm line 57
Moose::with('Moose::Meta::Class=HASH(0x8fc0810)', 'Role') called
at
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Moose/Exporter.pm
line 293
Moose::with('Role') called at test.pl line 18