File Coverage

blib/lib/Lexical/Importer.pm
Criterion Covered Total %
statement 32 32 100.0
branch 4 6 66.6
condition n/a
subroutine 9 9 100.0
pod 1 2 50.0
total 46 49 93.8


line stmt bran cond sub pod time code
1             package Lexical::Importer;
2 36     36   353752 use 5.012;
  36         77  
3 36     36   115 use warnings;
  36         36  
  36         792  
4 36     36   110 use strict;
  36         39  
  36         774  
5              
6 36     36   15409 use Lexical::SealRequireHints 0.006;
  36         20297  
  36         147  
7 36     36   17376 use Importer 0.013;
  36         110558  
  36         154  
8 36     36   13869 use parent 'Importer';
  36         7639  
  36         134  
9              
10             our $VERSION = "0.000005";
11              
12             require XSLoader;
13             XSLoader::load(__PACKAGE__, $VERSION);
14              
15             our %IMPORTED;
16              
17             sub import {
18 4     4   129 my $class = shift;
19 4         5 my $from = shift;
20 4         4 my $into = caller;
21 4         13 $class->SUPER::import_into($from, $into, \&set_symbol, @_);
22             }
23              
24             sub set_symbol {
25 7     7 0 748 my ($name, $ref, %info) = @_;
26 7 100       15 push @{$IMPORTED{$info{into}}} => $name if $info{sig} eq '&';
  4         7  
27 7         52 __PACKAGE__->_import_lex_var("$info{sig}$name" => $ref);
28             }
29              
30             sub do_unimport {
31 1     1 1 86 my $self = shift;
32              
33 1         3 my $from = $self->from;
34 1 50       4 my $imported = $IMPORTED{$from} or $self->croak("'$from' does not have any lexical imports to remove");
35              
36 1         2 my %allowed = map { $_ => 1 } @$imported;
  4         5  
37              
38 1 50       5 my @args = @_ ? @_ : @$imported;
39              
40 1         152 $self->_unimport_lex_sub($_) for @args;
41             }
42              
43              
44             1;
45              
46             __END__