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   16152 use warnings;
  1         2  
  1         28  
4 1     1   4 use strict;
  1         2  
  1         16  
5              
6 1     1   292 use Sub::Attribute;
  1         2  
  1         56  
7 1     1   7 use parent qw(Exporter);
  1         1  
  1         6  
8              
9             sub _attr_exporter_register{
10 4     4   9 my($class, $type, $sym, $tags) = @_;
11 4 50       10 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   80 no strict 'refs';
  1         2  
  1         128  
20 4         5 push @{$class . '::' . $type}, $name;
  4         12  
21              
22 4         8 \%{$class . '::EXPORT_TAGS'};
  4         7  
23             };
24              
25 4   100     8 push @{$export_tags->{all} ||= []}, $name;
  4         19  
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         11  
30             }
31             }
32 4         24 return;
33             }
34              
35             sub Export :ATTR_SUB{
36 1     1 1 521 my($class, $sym, undef, undef, $tags) = @_;
37 1         6 $class->_attr_exporter_register(EXPORT => $sym, $tags);
38 1     1   6 }
  1         2  
  1         4  
39              
40             sub Exportable :ATTR_SUB{
41 3     3 0 6 my($class, $sym, undef, undef, $tags) = @_;
42 3         7 $class->_attr_exporter_register(EXPORT_OK => $sym, $tags);
43 1     1   185 }
  1         3  
  1         3  
44              
45             1;
46             __END__