Permalink
Browse files

Move redefinition warnings to the method application hook so it's eas…

…y to override.
  • Loading branch information...
1 parent a04dfbd commit 703069aee1b235d381150f9c245d80619e660db0 @rafl committed Aug 14, 2009
Showing with 6 additions and 7 deletions.
  1. +6 −7 lib/MooseX/Method/Signatures.pm
View
13 lib/MooseX/Method/Signatures.pm
@@ -252,6 +252,12 @@ sub _parser {
? $self->custom_method_application
: sub {
my ($meta, $name, $method) = @_;
+
+ if (warnings::enabled("redefine") && (my $meta_meth = $meta->get_method($name))) {
+ warnings::warn("redefine", "Method $name redefined on package ${ \$meta->name }")
+ if $meta_meth->isa('MooseX::Method::Signatures::Meta::Method');
+ }
+
$meta->add_method($name => $method);
};
@@ -264,13 +270,6 @@ sub _parser {
my $meth = $create_meta_method->($code, $pkg, $name, @args);
my $meta = Moose::Meta::Class->initialize($pkg);
- my $meta_meth;
-
- if (warnings::enabled("redefine") &&
- ($meta_meth = $meta->get_method($name)) &&
- $meta_meth->isa('MooseX::Method::Signatures::Meta::Method')) {
- warnings::warn("redefine", "Method $name redefined on package $pkg");
- }
$meta->$apply($name, $meth);
return;

0 comments on commit 703069a

Please sign in to comment.