From: Hans Dieter Pearcey Date: Fri, 12 Oct 2007 03:09:44 +0000 (+0000) Subject: reinstate perigrin's into/into_level, hide _get_caller behind an underscore X-Git-Tag: 0_27~27 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c92c120567ee13c724b2721d3b73bb75354fdc1e;p=gitmo%2FMoose.git reinstate perigrin's into/into_level, hide _get_caller behind an underscore --- diff --git a/lib/Moose.pm b/lib/Moose.pm index 3574c98..5b577f7 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -203,13 +203,19 @@ use Moose::Util::TypeConstraints; } ); - + # 1 extra level because it's called by import so there's a layer of indirection + sub _get_caller{ + my $offset = 1; + return + ref $_[1] && defined $_[1]->{into} + ? $_[1]->{into} + : ref $_[1] && defined $_[1]->{into_level} + ? caller($offset + $_[1]->{into_level}) + : caller($offset); + } sub import { - $CALLER = ref $_[1] && defined $_[1]->{into} ? $_[1]->{into} - : ref $_[1] - && defined $_[1]->{into_level} ? caller( $_[1]->{into_level} ) - : caller(); + $CALLER = _get_caller(@_); strict->import; warnings->import; @@ -224,7 +230,7 @@ use Moose::Util::TypeConstraints; sub unimport { no strict 'refs'; - my $class = caller(); + my $class = _get_caller(@_); # loop through the exports ... foreach my $name ( keys %exports ) {