File Coverage

blib/lib/Method/Extension.pm
Criterion Covered Total %
statement 29 29 100.0
branch 1 2 50.0
condition n/a
subroutine 8 8 100.0
pod 0 1 0.0
total 38 40 95.0


line stmt bran cond sub pod time code
1             package Method::Extension;
2              
3 1     1   114353 use 5.006;
  1         5  
4 1     1   14 use strict;
  1         3  
  1         30  
5 1     1   15 use warnings;
  1         2  
  1         90  
6              
7             # ABSTRACT: Method Extension port for perl
8              
9             our $VERSION = "0.2";
10              
11 1     1   5 use base 'Attribute::Handlers';
  1         3  
  1         878  
12              
13             sub UNIVERSAL::ExtensionMethod : ATTR(CODE) {
14 1     1 0 2905 my ( $symbol, $referent, $packages ) = @_[ 1, 2, 4 ];
15              
16 1         2 my $original_method_name = *{$symbol}{NAME};
  1         3  
17              
18 1 50       26 $packages = [$packages] unless ref $packages eq 'ARRAY';
19              
20 1         2 foreach my $package ( @{$packages} ) {
  1         4  
21             {
22 1     1   14231 no strict 'refs';
  1         2  
  1         43  
  1         2  
23 1     1   5 use warnings FATAL => 'uninitialized';
  1         2  
  1         161  
24              
25 1         2 *{"$package\::$original_method_name"} = $referent;
  1         9  
26             }
27             }
28 1     1   7 }
  1         2  
  1         7  
29              
30             1;
31             __END__