line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
17
|
use 5.010; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
40
|
|
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
{ |
6
|
|
|
|
|
|
|
package Refinements::Package; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use Exporter::Tiny (); |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
16
|
|
9
|
1
|
|
|
1
|
|
887
|
use Method::Lexical (); |
|
1
|
|
|
|
|
340481
|
|
|
1
|
|
|
|
|
39
|
|
10
|
1
|
|
|
1
|
|
12
|
use Module::Runtime qw( use_package_optimistically ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
13
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
14
|
|
|
|
|
|
|
our @ISA = qw( Method::Lexical ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub add_refinement |
17
|
|
|
|
|
|
|
{ |
18
|
1
|
|
|
1
|
1
|
4
|
my $class = shift; |
19
|
1
|
|
|
|
|
2
|
my ($fqname, $coderef) = @_; |
20
|
|
|
|
|
|
|
|
21
|
1
|
50
|
|
|
|
10
|
my ($package, $subname) = ($fqname =~ /^(.+)::(\w+)$/) |
22
|
|
|
|
|
|
|
or Exporter::Tiny::_croak('Could not split "%s" as a fully qualified sub name', $fqname); |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
252
|
$Refinements::REFINEMENTS{$class}{$fqname} = $coderef; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub get_refinement |
28
|
|
|
|
|
|
|
{ |
29
|
3
|
|
|
3
|
1
|
7
|
my $class = shift; |
30
|
3
|
|
|
|
|
6
|
my ($fqname) = @_; |
31
|
3
|
|
|
|
|
20
|
$Refinements::REFINEMENTS{$class}{$fqname}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub has_refinement |
35
|
|
|
|
|
|
|
{ |
36
|
3
|
|
|
3
|
1
|
991
|
my $class = shift; |
37
|
3
|
|
|
|
|
5
|
my ($fqname) = @_; |
38
|
3
|
|
|
|
|
21
|
exists($Refinements::REFINEMENTS{$class}{$fqname}); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub get_refinement_names |
42
|
|
|
|
|
|
|
{ |
43
|
1
|
|
|
1
|
1
|
9
|
my $class = shift; |
44
|
1
|
|
|
|
|
1
|
keys %{ $Refinements::REFINEMENTS{$class} }; |
|
1
|
|
|
|
|
5
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $wrap = sub |
48
|
|
|
|
|
|
|
{ |
49
|
|
|
|
|
|
|
my $class = shift; |
50
|
|
|
|
|
|
|
my ($fqname, $coderef) = @_; |
51
|
|
|
|
|
|
|
my ($package, $subname) = ($fqname =~ /^(.+)::(\w+)$/); |
52
|
|
|
|
|
|
|
use_package_optimistically($package); |
53
|
|
|
|
|
|
|
my $orig = $package->can($subname); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
return sub |
56
|
|
|
|
|
|
|
{ |
57
|
|
|
|
|
|
|
my $curr = $_[0]->can($subname); |
58
|
|
|
|
|
|
|
if ($curr == $orig) |
59
|
|
|
|
|
|
|
{ |
60
|
|
|
|
|
|
|
unshift @_, $orig; |
61
|
|
|
|
|
|
|
goto $coderef; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
goto $curr; |
64
|
|
|
|
|
|
|
}; |
65
|
|
|
|
|
|
|
}; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub import |
68
|
|
|
|
|
|
|
{ |
69
|
1
|
|
|
1
|
|
10
|
my $class = shift; |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
2
|
my @refinements = map { |
72
|
1
|
|
|
|
|
11
|
my $name = $_; |
73
|
1
|
|
|
|
|
6
|
my $code = $class->$wrap( $name, $class->get_refinement($name) ); |
74
|
1
|
|
|
|
|
14
|
$name => $code; |
75
|
|
|
|
|
|
|
} $class->get_refinement_names; |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
11
|
$class->SUPER::import(@refinements); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |