line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Method::Modifiers::Fast; |
2
|
24
|
|
|
24
|
|
77674
|
use strict; |
|
24
|
|
|
|
|
55
|
|
|
24
|
|
|
|
|
1316
|
|
3
|
24
|
|
|
24
|
|
132
|
use warnings; |
|
24
|
|
|
|
|
51
|
|
|
24
|
|
|
|
|
1614
|
|
4
|
24
|
|
|
24
|
|
40492
|
use Data::Util; |
|
24
|
|
|
|
|
37618
|
|
|
24
|
|
|
|
|
2061
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.041'; |
6
|
|
|
|
|
|
|
|
7
|
24
|
|
|
24
|
|
197
|
use base 'Exporter'; |
|
24
|
|
|
|
|
854
|
|
|
24
|
|
|
|
|
6860
|
|
8
|
|
|
|
|
|
|
our @EXPORT = qw(before after around); |
9
|
|
|
|
|
|
|
our @EXPORT_OK = (@EXPORT, 'install_modifier'); |
10
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
11
|
|
|
|
|
|
|
moose => [qw(before after around)], |
12
|
|
|
|
|
|
|
all => \@EXPORT_OK, |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
24
|
|
|
24
|
|
421
|
use Carp 'confess'; |
|
24
|
|
|
|
|
57
|
|
|
24
|
|
|
|
|
18218
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _install_modifier; # -w |
18
|
|
|
|
|
|
|
*_install_modifier = \&install_modifier; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub install_modifier { |
21
|
93
|
|
|
93
|
0
|
216
|
my $into = shift; |
22
|
93
|
|
|
|
|
133
|
my $type = shift; |
23
|
93
|
|
|
|
|
137
|
my $modifier = pop; |
24
|
93
|
|
|
|
|
221
|
my @names = @_; |
25
|
|
|
|
|
|
|
|
26
|
93
|
|
|
|
|
314
|
foreach my $name (@names) { |
27
|
95
|
|
|
|
|
357
|
my $method = Data::Util::get_code_ref( $into, $name ); |
28
|
|
|
|
|
|
|
|
29
|
95
|
100
|
100
|
|
|
1745
|
if ( !$method || !Data::Util::subroutine_modifier($method) ) { |
30
|
|
|
|
|
|
|
|
31
|
47
|
100
|
|
|
|
161
|
unless ($method) { |
32
|
37
|
100
|
|
|
|
671
|
$method = $into->can($name) |
33
|
|
|
|
|
|
|
or confess |
34
|
|
|
|
|
|
|
"The method '$name' is not found in the inheritance hierarchy for class $into"; |
35
|
|
|
|
|
|
|
} |
36
|
43
|
|
|
|
|
686
|
$method = Data::Util::modify_subroutine( $method, |
37
|
|
|
|
|
|
|
$type => [$modifier] ); |
38
|
|
|
|
|
|
|
|
39
|
24
|
|
|
24
|
|
176
|
no warnings 'redefine'; |
|
24
|
|
|
|
|
52
|
|
|
24
|
|
|
|
|
13390
|
|
40
|
43
|
|
|
|
|
435
|
Data::Util::install_subroutine( $into, $name => $method ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
else { |
43
|
48
|
|
|
|
|
272
|
Data::Util::subroutine_modifier( $method, $type => $modifier ); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
89
|
|
|
|
|
29177
|
return; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub before { |
50
|
27
|
|
|
27
|
1
|
2652
|
_install_modifier( scalar(caller), 'before', @_ ); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub after { |
54
|
26
|
|
|
26
|
1
|
912
|
_install_modifier( scalar(caller), 'after', @_ ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub around { |
58
|
40
|
|
|
40
|
1
|
2461
|
_install_modifier( scalar(caller), 'around', @_ ); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |