include test for failure mode
[catagits/Catalyst-Runtime.git] / lib / Catalyst / ClassData.pm
index f7761e9..0f0b27d 100644 (file)
@@ -12,6 +12,7 @@ sub mk_classdata {
   my $slot = '$'.$attribute;
   my $accessor =  sub {
     my $pkg = ref $_[0] || $_[0];
+    # Hack - delberately create a metaclass instance
     my $meta = $pkg->Class::MOP::Object::meta();
     if (@_ > 1) {
       $meta->namespace->{$attribute} = \$_[1];
@@ -43,6 +44,8 @@ sub mk_classdata {
     unless ref $accessor eq 'CODE';
 
   my $meta = $class->Class::MOP::Object::meta();
+  confess "${class}'s metaclass is not a Class::MOP::Class"
+    unless $meta->isa('Class::MOP::Class');
   my $immutable_options;
   if( $meta->is_immutable ){
     $immutable_options = $meta->get_immutable_options;