Simplify Mouse::Meta::Role::Composite::_apply_methods()
gfx [Mon, 8 Feb 2010 04:38:03 +0000 (13:38 +0900)]
lib/Mouse/Meta/Role/Composite.pm

index 771520b..956367d 100644 (file)
@@ -84,21 +84,19 @@ sub _apply_methods{
     if(exists $self->{conflicting_methods}){
         my $consumer_class_name = $consumer->name;
 
-        my @conflicting = sort grep{ !$consumer_class_name->can($_) } keys %{ $self->{conflicting_methods} };
+        my @conflicting = grep{ !$consumer_class_name->can($_) } keys %{ $self->{conflicting_methods} };
 
         if(@conflicting == 1){
             my $method_name = $conflicting[0];
-            my @roles       = sort @{ $self->{composed_roles_by_method}{$method_name} };
+            my $roles       = Mouse::Util::quoted_english_list(map{ $_->name } @{ $self->{composed_roles_by_method}{$method_name} });
             $self->throw_error(
                sprintf q{Due to a method name conflict in roles %s, the method '%s' must be implemented or excluded by '%s'},
-                   Mouse::Util::quoted_english_list(map{ $_->name } @roles), $method_name, $consumer->name
+                   $roles, $method_name, $consumer_class_name
             );
         }
         elsif(@conflicting > 1){
-            my $methods = Mouse::Util::quoted_english_list(@conflicting);
-
             my %seen;
-            my $roles   = Mouse::Util::quoted_english_list(sort
+            my $roles = Mouse::Util::quoted_english_list(
                 grep{ !$seen{$_}++ } # uniq
                 map { $_->name }
                 map { @{$_} } @{ $self->{composed_roles_by_method} }{@conflicting}
@@ -106,7 +104,9 @@ sub _apply_methods{
 
             $self->throw_error(
                sprintf q{Due to method name conflicts in roles %s, the methods %s must be implemented or excluded by '%s'},
-                   $roles, $methods, $consumer->name
+                   $roles,
+                   Mouse::Util::quoted_english_list(@conflicting),
+                   $consumer_class_name
             );
         }
     }