add Sub::Exporter style caller() discovery
Chris Prather [Sun, 16 Sep 2007 13:48:34 +0000 (13:48 +0000)]
lib/Moose/Role.pm

index 2e6b187..55c283d 100644 (file)
@@ -159,7 +159,12 @@ use Moose::Util::TypeConstraints;
     });
     
     sub import {
-        $CALLER = caller();
+        $CALLER =
+            ref $_[1] && defined $_[1]->{into} ? $_[1]->{into}
+          : ref $_[1]
+          && defined $_[1]->{into_level} ? caller( $_[1]->{into_level} )
+          :                                caller();
+
         
         strict->import;
         warnings->import;