From: gfx Date: Mon, 8 Feb 2010 04:38:03 +0000 (+0900) Subject: Simplify Mouse::Meta::Role::Composite::_apply_methods() X-Git-Tag: 0.50~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=aba0f138748fe950b6819e8d3ec474a6046207c5;p=gitmo%2FMouse.git Simplify Mouse::Meta::Role::Composite::_apply_methods() --- diff --git a/lib/Mouse/Meta/Role/Composite.pm b/lib/Mouse/Meta/Role/Composite.pm index 771520b..956367d 100644 --- a/lib/Mouse/Meta/Role/Composite.pm +++ b/lib/Mouse/Meta/Role/Composite.pm @@ -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 ); } }