X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FRole%2FApplication%2FToRole.pm;h=49ca840d3ccbfb691f8f6bdd33f1615a83c67e89;hb=8de5717850eb1f406e5f71d2ccfac33c72cc490b;hp=cd08d1c6b729e8e8001a023e2ba5a0c2b26c22b0;hpb=dbe21639d532a07229d0beeffafafba66a7e26f5;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Role/Application/ToRole.pm b/lib/Moose/Meta/Role/Application/ToRole.pm index cd08d1c..49ca840 100644 --- a/lib/Moose/Meta/Role/Application/ToRole.pm +++ b/lib/Moose/Meta/Role/Application/ToRole.pm @@ -6,7 +6,7 @@ use metaclass; use Scalar::Util 'blessed'; -our $VERSION = '0.79'; +our $VERSION = '0.92'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -35,11 +35,12 @@ sub check_role_exclusions { sub check_required_methods { my ($self, $role1, $role2) = @_; - foreach my $required_method_name ($role1->get_required_method_list) { + foreach my $required_method ($role1->get_required_method_list) { + my $required_method_name = $required_method->name; next if $self->is_aliased_method($required_method_name); - $role2->add_required_methods($required_method_name) + $role2->add_required_methods($required_method) unless $role2->find_method_by_name($required_method_name); } } @@ -72,12 +73,32 @@ sub apply_attributes { sub apply_methods { my ($self, $role1, $role2) = @_; foreach my $method_name ($role1->get_method_list) { + next if $method_name eq 'meta'; + + unless ( $self->is_method_excluded($method_name) ) { + if ( $role2->has_method($method_name) + && $role2->get_method($method_name)->body + != $role1->get_method($method_name)->body ) { + + # method conflicts between roles result in the method becoming + # a requirement + $role2->add_conflicting_method( + name => $method_name, + roles => [ $role1->name, $role2->name ], + ); + } + else { + $role2->add_method( + $method_name, + $role1->get_method($method_name) + ); + } + } if ($self->is_method_aliased($method_name)) { my $aliased_method_name = $self->get_method_aliases->{$method_name}; - # it if it has one already + if ($role2->has_method($aliased_method_name) && - # and if they are not the same thing ... $role2->get_method($aliased_method_name)->body != $role1->get_method($method_name)->body) { require Moose; @@ -93,29 +114,7 @@ sub apply_methods { $role2->add_required_methods($method_name) unless $self->is_method_excluded($method_name); } - - next; - } - - next if $self->is_method_excluded($method_name); - - # it if it has one already - if ($role2->has_method($method_name) && - # and if they are not the same thing ... - $role2->get_method($method_name)->body != $role1->get_method($method_name)->body) { - # method conflicts between roles result - # in the method becoming a requirement - $role2->add_required_methods($method_name); - } - else { - # add it, although it could be overridden - $role2->add_method( - $method_name, - $role1->get_method($method_name) - ); - } - } }