From: Dave Rolsky Date: Tue, 7 Jul 2009 18:07:57 +0000 (-0500) Subject: really try to make method modifier names unique X-Git-Tag: 0.90~28 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4884b0cd5dd83114eba79aa05372cb0d52309f80;p=gitmo%2FClass-MOP.git really try to make method modifier names unique --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 24234b8..9f2f06f 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -666,13 +666,14 @@ sub add_method { return $method; }; + my $counter = 0; sub add_before_method_modifier { my ($self, $method_name, $method_modifier) = @_; (defined $method_name && $method_name) || confess "You must pass in a method name"; my $method = $fetch_and_prepare_method->($self, $method_name); $method->add_before_modifier( - subname(':before-' . $method_name => $method_modifier) + subname(':before-' . $counter++ . q{-} . $method_name => $method_modifier) ); } @@ -682,7 +683,7 @@ sub add_method { || confess "You must pass in a method name"; my $method = $fetch_and_prepare_method->($self, $method_name); $method->add_after_modifier( - subname(':after-' . $method_name => $method_modifier) + subname(':after-' . $counter++ . q{-} . $method_name => $method_modifier) ); } @@ -692,7 +693,7 @@ sub add_method { || confess "You must pass in a method name"; my $method = $fetch_and_prepare_method->($self, $method_name); $method->add_around_modifier( - subname(':around-' . $method_name => $method_modifier) + subname(':around-' . $counter++ . q{-} . $method_name => $method_modifier) ); } diff --git a/t/031_method_modifiers.t b/t/031_method_modifiers.t index 3b04428..f6f6dcd 100644 --- a/t/031_method_modifiers.t +++ b/t/031_method_modifiers.t @@ -225,6 +225,6 @@ use Class::MOP::Method; } { - is( Foo->orig1, 'Class::MOP::Class:::around-orig1', 'each modifier gets a unique name' ); - is( Foo->orig2, 'Class::MOP::Class:::around-orig2', 'each modifier gets a unique name' ); + is( Foo->orig1, 'Class::MOP::Class:::around-18-orig1', 'each modifier gets a unique name' ); + is( Foo->orig2, 'Class::MOP::Class:::around-19-orig2', 'each modifier gets a unique name' ); }