X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FRole%2FComposite.pm;h=771520b986467f4d8650146ddbf83539538e72d9;hp=3dd72a495a3b82ab820770234ad8be23b7726dc3;hb=5af36247683101e3c457450489486d41f0bd7101;hpb=034587d897c53d4df84085a9229334bd2d51f1c6 diff --git a/lib/Mouse/Meta/Role/Composite.pm b/lib/Mouse/Meta/Role/Composite.pm index 3dd72a4..771520b 100644 --- a/lib/Mouse/Meta/Role/Composite.pm +++ b/lib/Mouse/Meta/Role/Composite.pm @@ -1,5 +1,5 @@ package Mouse::Meta::Role::Composite; -use Mouse::Util qw(english_list); # enables strict and warnings +use Mouse::Util; # enables strict and warnings use Mouse::Meta::Role; our @ISA = qw(Mouse::Meta::Role); @@ -50,7 +50,9 @@ sub has_override_method_modifier{ } sub add_attribute{ - my($self, $attr_name, $spec) = @_; + my $self = shift; + my $attr_name = shift; + my $spec = (@_ == 1 ? $_[0] : {@_}); my $existing = $self->{attributes}{$attr_name}; if($existing && $existing != $spec){ @@ -77,38 +79,39 @@ sub add_override_method_modifier{ # components of apply() sub _apply_methods{ - my($self, $applicant, $args) = @_; + my($self, $consumer, $args) = @_; if(exists $self->{conflicting_methods}){ - my $applicant_class_name = $applicant->name; + my $consumer_class_name = $consumer->name; - my @conflicting = sort grep{ !$applicant_class_name->can($_) } keys %{ $self->{conflicting_methods} }; + my @conflicting = sort 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} }; $self->throw_error( sprintf q{Due to a method name conflict in roles %s, the method '%s' must be implemented or excluded by '%s'}, - english_list(map{ sprintf q{'%s'}, $_->name } @roles), $method_name, $applicant->name + Mouse::Util::quoted_english_list(map{ $_->name } @roles), $method_name, $consumer->name ); } elsif(@conflicting > 1){ - my $methods = english_list(map{ sprintf q{'%s'}, $_ } @conflicting); + my $methods = Mouse::Util::quoted_english_list(@conflicting); my %seen; - my $roles = english_list( - sort map{ my $name = $_->name; $seen{$name}++ ? () : sprintf q{'%s'}, $name } - map{ @{$_} } @{ $self->{composed_roles_by_method} }{@conflicting} + my $roles = Mouse::Util::quoted_english_list(sort + grep{ !$seen{$_}++ } # uniq + map { $_->name } + map { @{$_} } @{ $self->{composed_roles_by_method} }{@conflicting} ); $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, $applicant->name + $roles, $methods, $consumer->name ); } } - $self->SUPER::_apply_methods($applicant, $args); + $self->SUPER::_apply_methods($consumer, $args); return; } 1; @@ -120,7 +123,7 @@ Mouse::Meta::Role::Composite - An object to represent the set of roles =head1 VERSION -This document describes Mouse version 0.40 +This document describes Mouse version 0.49 =head1 SEE ALSO