From: Chris Prather Date: Thu, 13 Sep 2007 14:22:38 +0000 (+0000) Subject: support into and into_level better, and make _init_meta useable by others X-Git-Tag: 0_26~22 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=72bbc189e087e8f3dedc2d0133d2d0bdf6efa65d;p=gitmo%2FMoose.git support into and into_level better, and make _init_meta useable by others --- diff --git a/lib/Moose.pm b/lib/Moose.pm index 18f2a91..ef7662a 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -29,9 +29,10 @@ use Moose::Util::TypeConstraints; { my $CALLER; - + sub _init_meta { - my $class = $CALLER; + my ($class, $base_class) = @_; + $base_class = $class unless defined $base_class; # make a subtype for each Moose class subtype $class @@ -65,7 +66,7 @@ use Moose::Util::TypeConstraints; } # make sure they inherit from Moose::Object - $meta->superclasses('Moose::Object') + $meta->superclasses($base_class) unless $meta->superclasses(); } @@ -194,16 +195,18 @@ use Moose::Util::TypeConstraints; } }); - sub import { - $CALLER = caller(); - + sub import { + $CALLER + = ref $_[1] && defined $_[1]->{into} ? $_[1]->{into} + : ref $_[1] && defined $_[1]->{into_level} ? caller($_[1]->{into_level}) + : caller(); strict->import; warnings->import; # we should never export to main return if $CALLER eq 'main'; - _init_meta(); + _init_meta($CALLER, 'Moose::Object'); goto $exporter; }