Need to use _add_meta_method from new Moose onwards to avoid warnings
Tomas Doran [Wed, 29 Sep 2010 00:27:11 +0000 (00:27 +0000)]
Changes
lib/Catalyst.pm
t/lib/TestApp/Controller/Anon.pm

diff --git a/Changes b/Changes
index e730104..331d18f 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 # This file documents the revision history for Perl extension Catalyst.
 
+  - Deal with Moose >= 1.15 warning if you add a method called 'meta' to a
+    class which already has one by using _add_meta_method.
+
 5.80028 2010-09-28 20:49:00
 
  Bug fixes:
index dd90aef..f72d3ce 100644 (file)
@@ -100,7 +100,12 @@ sub import {
     $meta->superclasses(grep { $_ ne 'Moose::Object' } $meta->superclasses);
 
     unless( $meta->has_method('meta') ){
-        $meta->add_method(meta => sub { Moose::Meta::Class->initialize("${caller}") } );
+        if ($Moose::VERSION >= 1.15) {
+            $meta->_add_meta_method('meta');
+        }
+        else {
+            $meta->add_method(meta => sub { Moose::Meta::Class->initialize("${caller}") } );
+        }
     }
 
     $caller->arguments( [@arguments] );
index 68b4fd6..1bc3698 100644 (file)
@@ -25,7 +25,6 @@ sub COMPONENT { # Don't do this yourself, use CatalystX::Component::Traits!
     # Special move as the methodattributes trait has changed our metaclass..
     $meta = find_meta($meta->name);
 
-    $meta->add_method('meta' => sub { $meta });
     $class = $meta->name;
     $class->new($app, $args);
 }