From: Stevan Little Date: Tue, 26 Feb 2008 15:39:29 +0000 (+0000) Subject: ovids bug X-Git-Tag: 0_64~84 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8861fab24df7ccdc253ecca72db02fc2a723e901;p=gitmo%2FClass-MOP.git ovids bug --- diff --git a/Changes b/Changes index ba140f0..fba4db9 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,12 @@ Revision history for Perl extension Class-MOP. 0.54 + * Class::MOP + metaclass + - making sure that load_class never gets + passed a value from @_ or $_ to squash + Ovid's bug (http://use.perl.org/~Ovid/journal/35763) + * Class::MOP::Class - make_{immutable,mutable} now return 1 (cause Sartak asked) diff --git a/lib/Class/MOP.pm b/lib/Class/MOP.pm index 619fca7..bcaf6a8 100644 --- a/lib/Class/MOP.pm +++ b/lib/Class/MOP.pm @@ -77,9 +77,9 @@ sub is_class_loaded { my $class = shift; no strict 'refs'; return 1 if defined ${"${class}::VERSION"} || defined @{"${class}::ISA"}; - foreach (keys %{"${class}::"}) { - next if substr($_, -2, 2) eq '::'; - return 1 if defined &{"${class}::$_"}; + foreach my $symbol (keys %{"${class}::"}) { + next if substr($symbol, -2, 2) eq '::'; + return 1 if defined &{"${class}::${symbol}"}; } return 0; } diff --git a/lib/metaclass.pm b/lib/metaclass.pm index 2b048db..1a388d2 100644 --- a/lib/metaclass.pm +++ b/lib/metaclass.pm @@ -7,7 +7,7 @@ use warnings; use Carp 'confess'; use Scalar::Util 'blessed'; -our $VERSION = '0.04'; +our $VERSION = '0.05'; our $AUTHORITY = 'cpan:STEVAN'; use Class::MOP; @@ -26,9 +26,14 @@ sub import { || confess "The metaclass ($metaclass) must be derived from Class::MOP::Class"; } my %options = @_; - #make sure the custom metaclasses get loaded - map{ Class::MOP::load_class($options{$_}) } - grep{ /^(attribute|method|instance)_metaclass/ } keys %options; + + # make sure the custom metaclasses get loaded + foreach my $class (grep { + /^(attribute|method|instance)_metaclass/ + } keys %options) { + Class::MOP::load_class($options{$class}) + } + my $package = caller(); # create a meta object so we can install &meta