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   341240 use 5.012;
  36         83  
3 36     36   112 use warnings;
  36         34  
  36         795  
4 36     36   99 use strict;
  36         40  
  36         738  
5              
6 36     36   14730 use Lexical::SealRequireHints 0.006;
  36         19893  
  36         129  
7 36     36   16839 use Importer 0.013;
  36         110274  
  36         158  
8 36     36   13819 use parent 'Importer';
  36         7684  
  36         143  
9              
10             our $VERSION = "0.000004";
11              
12             require XSLoader;
13             XSLoader::load(__PACKAGE__, $VERSION);
14              
15             our %IMPORTED;
16              
17             sub import {
18 4     4   126 my $class = shift;
19 4         3 my $from = shift;
20 4         4 my $into = caller;
21 4         14 $class->SUPER::import_into($from, $into, \&set_symbol, @_);
22             }
23              
24             sub set_symbol {
25 7     7 0 779 my ($name, $ref, %info) = @_;
26 7 100       13 push @{$IMPORTED{$info{into}}} => $name if $info{sig} eq '&';
  4         7  
27 7         49 __PACKAGE__->_import_lex_var("$info{sig}$name" => $ref);
28             }
29              
30             sub do_unimport {
31 1     1 1 88 my $self = shift;
32              
33 1         2 my $from = $self->from;
34 1 50       5 my $imported = $IMPORTED{$from} or $self->croak("'$from' does not have any lexical imports to remove");
35              
36 1         1 my %allowed = map { $_ => 1 } @$imported;
  4         6  
37              
38 1 50       4 my @args = @_ ? @_ : @$imported;
39              
40 1         151 $self->_unimport_lex_sub($_) for @args;
41             }
42              
43              
44             1;
45              
46             __END__