| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Import::Into; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 24571 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 37 |  | 
| 4 | 1 |  |  | 1 |  | 3 | use warnings FATAL => 'all'; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 40 |  | 
| 5 | 1 |  |  | 1 |  | 514 | use Module::Runtime; | 
|  | 1 |  |  |  |  | 1331 |  | 
|  | 1 |  |  |  |  | 5 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | our $VERSION = '1.002005'; | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | sub _prelude { | 
| 10 | 6 |  |  | 6 |  | 6 | my $target = shift; | 
| 11 |  |  |  |  |  |  | my ($package, $file, $line, $level) | 
| 12 | 6 | 100 |  |  |  | 22 | = ref $target         ? @{$target}{qw(package filename line level)} | 
|  | 2 | 100 |  |  |  | 5 |  | 
| 13 |  |  |  |  |  |  | : $target =~ /[^0-9]/ ? ($target) | 
| 14 |  |  |  |  |  |  | : (undef, undef, undef, $target); | 
| 15 | 6 | 100 |  |  |  | 12 | if (defined $level) { | 
| 16 | 2 |  |  |  |  | 9 | my ($p, $fn, $ln) = caller($level + 2); | 
| 17 | 2 |  | 33 |  |  | 9 | $package ||= $p; | 
| 18 | 2 |  | 33 |  |  | 6 | $file    ||= $fn; | 
| 19 | 2 |  | 33 |  |  | 6 | $line    ||= $ln; | 
| 20 |  |  |  |  |  |  | } | 
| 21 |  |  |  |  |  |  | qq{package $package;\n} | 
| 22 | 6 | 100 |  |  |  | 585 | . ($file ? "#line $line \"$file\"\n" : '') | 
| 23 |  |  |  |  |  |  | } | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | sub _make_action { | 
| 26 | 6 |  |  | 6 |  | 7 | my ($action, $target) = @_; | 
| 27 | 6 |  | 66 |  |  | 18 | my $version = ref $target && $target->{version}; | 
| 28 |  |  |  |  |  |  | eval _prelude($target) | 
| 29 |  |  |  |  |  |  | . q[sub {] | 
| 30 |  |  |  |  |  |  | . q[  my $module = shift;] | 
| 31 |  |  |  |  |  |  | . q[  Module::Runtime::require_module($module);] | 
| 32 | 6 | 100 | 66 |  |  | 11 | . (ref $target && exists $target->{version} ? q[  $module->VERSION($version);] : q[]) | 
|  |  | 50 |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | . q[  $module->].$action.q[(@_);] | 
| 34 |  |  |  |  |  |  | . q[}] | 
| 35 |  |  |  |  |  |  | or die "Failed to build action sub to ${action} for ${target}: $@"; | 
| 36 |  |  |  |  |  |  | } | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | sub import::into { | 
| 39 | 6 |  |  | 6 |  | 9879 | my ($class, $target, @args) = @_; | 
| 40 | 6 |  |  |  |  | 13 | _make_action(import => $target)->($class, @args); | 
| 41 |  |  |  |  |  |  | } | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | sub unimport::out_of { | 
| 44 | 0 |  |  | 0 |  |  | my ($class, $target, @args) = @_; | 
| 45 | 0 |  |  |  |  |  | _make_action(unimport => $target)->($class, @args); | 
| 46 |  |  |  |  |  |  | } | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | 1; | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | __END__ |