On Tue, Apr 14, 2009 at 2:15 PM, Chris Prather <[email protected]> wrote:
> Roles by default will drop conflicting methods on the floor. However you can
> optionally remap method names and or exclude method names.
>
> If you were to remap thr validate methods then in you main class write a
> single validate that called them that would be the cleanest solution.
Hmm,
I tried the Piotrs solution (with one simplification) - and it worked:
{
package Role::A;
use Moose::Role;
after 'validate' => sub {
print "Role::A\n";
}
}
{
package Role::B;
use Moose::Role;
after 'validate' => sub {
print "Role::B\n";
}
}
{
package Role::C;
use Moose::Role;
after 'validate' => sub {
print "Role::C\n";
}
}
{
package MainClass;
use Moose;
with 'Role::A';
with 'Role::B';
with 'Role::C';
sub validate {};
}
package Main;
my $object = MainClass->new();
$object->validate;
__OUTPUT__
z...@zby:~/progs/html-formhandler$ perl modifiers_in_roles.pl
Role::A
Role::B
Role::C
z...@zby:~/progs/html-formhandler$
Just what I wanted. Or do I miss something?
Cheers,
Zbigniew