From: Shawn M Moore Date: Wed, 15 Apr 2009 20:33:56 +0000 (-0400) Subject: Pull -metaclass out of the import line X-Git-Tag: 0.75~12 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8f30b86e09b01c3bad5e08a6e64242619bdd057f;p=gitmo%2FMoose.git Pull -metaclass out of the import line --- diff --git a/lib/Moose/Exporter.pm b/lib/Moose/Exporter.pm index 9f0771d..d62f1cf 100644 --- a/lib/Moose/Exporter.pm +++ b/lib/Moose/Exporter.pm @@ -227,6 +227,9 @@ sub _make_import_sub { my $traits; ( $traits, @_ ) = _strip_traits(@_); + my $metaclass; + ( $metaclass, @_ ) = _strip_metaclass(@_); + # Normally we could look at $_[0], but in some weird cases # (involving goto &Moose::import), $_[0] ends as something # else (like Squirrel). @@ -293,6 +296,18 @@ sub _strip_traits { return ( $traits, @_ ); } +sub _strip_metaclass { + my $idx = first_index { $_ eq '-metaclass' } @_; + + return ( undef, @_ ) unless $idx >= 0 && $#_ >= $idx + 1; + + my $metaclass = $_[ $idx + 1 ]; + + splice @_, $idx, 2; + + return ( $metaclass, @_ ); +} + sub _apply_meta_traits { my ( $class, $traits ) = @_;