And fix it properly.
Tomas Doran [Thu, 2 Apr 2009 00:40:57 +0000 (00:40 +0000)]
lib/Catalyst.pm
lib/Catalyst/ClassData.pm
lib/Catalyst/Controller.pm

index 8805134..282b71f 100644 (file)
@@ -2085,6 +2085,8 @@ sub setup_components {
 sub setup_component {
     my( $class, $component ) = @_;
 
+
+    #warn("Component $component has meta " . $component->meta);
     unless ( $component->can( 'COMPONENT' ) ) {
         return $component;
     }
index 954d777..41bfaa1 100644 (file)
@@ -2,7 +2,7 @@ package Catalyst::ClassData;
 
 use Moose::Role;
 use Class::MOP;
-use Class::MOP::Object;
+use Moose::Util ();
 
 sub mk_classdata {
   my ($class, $attribute) = @_;
@@ -12,8 +12,8 @@ sub mk_classdata {
   my $slot = '$'.$attribute;
   my $accessor =  sub {
     my $pkg = ref $_[0] || $_[0];
-    # Hack - delberately create a metaclass instance
-    my $meta = $pkg->Moose::Object::meta();
+    my $meta = Moose::Util::find_meta($pkg) 
+        || Moose->init_meta( for_class => $pkg );
     if (@_ > 1) {
       $meta->namespace->{$attribute} = \$_[1];
       return $_[1];
index e79d79f..3b5ce45 100644 (file)
@@ -181,6 +181,8 @@ sub register_actions {
     #this is still not correct for some reason.
     my $namespace = $self->action_namespace($c);
     my $meta = find_meta($self);
+    confess("Wrong metaclass $meta for $self - " . $meta->name)
+        unless $meta->can('get_all_methods_with_attributes');
     my @methods = $meta->get_all_methods_with_attributes;
 
     foreach my $method (@methods) {