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