File Coverage

example/lib/Attribute/Exporter.pm
Criterion Covered Total %
statement 41 43 95.3
branch 3 4 75.0
condition 4 4 100.0
subroutine 10 10 100.0
pod 1 2 50.0
total 59 63 93.6


line stmt bran cond sub pod time code
1             package Attribute::Exporter;
2              
3 1     1   70003 use warnings;
  1         13  
  1         38  
4 1     1   5 use strict;
  1         2  
  1         20  
5              
6 1     1   393 use Sub::Attribute;
  1         4  
  1         61  
7 1     1   7 use parent qw(Exporter);
  1         2  
  1         5  
8              
9             sub _attr_exporter_register{
10 4     4   8 my($class, $type, $sym, $tags) = @_;
11 4 50       11 unless($sym){
12 0         0 require Carp;
13 0         0 Carp::croak('Cannot export anonymous subroutine');
14             }
15              
16 4         6 my $name = *{$sym}{NAME};
  4         8  
17              
18 4         6 my $export_tags = do{
19 1     1   96 no strict 'refs';
  1         2  
  1         155  
20 4         6 push @{$class . '::' . $type}, $name;
  4         15  
21              
22 4         5 \%{$class . '::EXPORT_TAGS'};
  4         10  
23             };
24              
25 4   100     6 push @{$export_tags->{all} ||= []}, $name;
  4         24  
26              
27 4 100       10 if($tags){
28 3         7 foreach my $tag(split q{ }, $tags){
29 3   100     4 push @{$export_tags->{$tag} ||= []}, $name;
  3         12  
30             }
31             }
32 4         30 return;
33             }
34              
35             sub Export :ATTR_SUB{
36 1     1 1 640 my($class, $sym, undef, undef, $tags) = @_;
37 1         7 $class->_attr_exporter_register(EXPORT => $sym, $tags);
38 1     1   7 }
  1         2  
  1         5  
39              
40             sub Exportable :ATTR_SUB{
41 3     3 0 13 my($class, $sym, undef, undef, $tags) = @_;
42 3         8 $class->_attr_exporter_register(EXPORT_OK => $sym, $tags);
43 1     1   272 }
  1         2  
  1         4  
44              
45             1;
46             __END__