From: Yuval Kogman Date: Tue, 16 Sep 2008 17:52:40 +0000 (+0000) Subject: load metaclasses more liberally X-Git-Tag: 0.66~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=de12105af7ffc364e31cd063dfa8ca57a9c7120d;p=gitmo%2FClass-MOP.git load metaclasses more liberally --- diff --git a/lib/metaclass.pm b/lib/metaclass.pm index eccb380..6b29ef1 100644 --- a/lib/metaclass.pm +++ b/lib/metaclass.pm @@ -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 index 0000000..afa8d46 --- /dev/null +++ b/t/lib/MyMetaClass/Random.pm @@ -0,0 +1,7 @@ + +package MyMetaClass::Random; + +use strict; +use warnings; + +1;