load metaclasses more liberally
Yuval Kogman [Tue, 16 Sep 2008 17:52:40 +0000 (17:52 +0000)]
lib/metaclass.pm
t/lib/MyMetaClass/Random.pm [new file with mode: 0644]

index eccb380..6b29ef1 100644 (file)
@@ -31,10 +31,10 @@ sub import {
         || confess "The metaclass ($metaclass) must be derived from Class::MOP::Class";
 
     # make sure the custom metaclasses get loaded
-    foreach my $class (grep { 
-                            /^(attribute|method|instance)_metaclass/ 
-                        } keys %options) {
-        Class::MOP::load_class($options{$class})
+    foreach my $key (grep { /_(?:meta)?class$/ } keys %options) {
+        unless ( ref( my $class = $options{$key} ) ) {
+            Class::MOP::load_class($class)
+        }
     }
 
     my $package = caller();
diff --git a/t/lib/MyMetaClass/Random.pm b/t/lib/MyMetaClass/Random.pm
new file mode 100644 (file)
index 0000000..afa8d46
--- /dev/null
@@ -0,0 +1,7 @@
+
+package MyMetaClass::Random;
+
+use strict;
+use warnings;
+
+1;