line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Component::Component::Autocall::InjectMethod; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
29
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
171
|
|
4
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
128
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
22
|
use Carp::Clan qw/Class::Component/; |
|
4
|
|
|
|
|
102
|
|
|
4
|
|
|
|
|
42
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub register_method { |
9
|
13
|
|
|
13
|
0
|
51
|
my($self, @methods) = @_; |
10
|
13
|
|
66
|
|
|
46
|
my $class = ref($self) || $self; |
11
|
|
|
|
|
|
|
|
12
|
13
|
|
|
|
|
73
|
$self->NEXT( register_method => @methods ); |
13
|
13
|
|
|
|
|
56
|
while (my($method, $plugin) = splice @methods, 0, 2) { |
14
|
13
|
50
|
|
|
|
63
|
next unless $plugin; |
15
|
4
|
|
|
4
|
|
937
|
no strict 'refs'; |
|
4
|
|
|
|
|
17
|
|
|
4
|
|
|
|
|
124
|
|
16
|
4
|
|
|
4
|
|
19
|
no warnings 'redefine'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
1341
|
|
17
|
13
|
100
|
|
|
|
42
|
unless (ref $plugin eq 'HASH') { |
18
|
10
|
|
|
8
|
|
53
|
*{"$class\::$method"} = sub { $plugin->$method(shift, @_) }; |
|
10
|
|
|
|
|
61
|
|
|
8
|
|
|
|
|
3639
|
|
19
|
10
|
|
|
|
|
127
|
next; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# extend method |
23
|
3
|
|
|
|
|
6
|
my $obj = $plugin; |
24
|
3
|
|
|
|
|
6
|
$plugin = $obj->{plugin}; |
25
|
3
|
|
|
|
|
8
|
my $real_method = $obj->{method}; |
26
|
3
|
50
|
33
|
|
|
51
|
next unless $plugin && $real_method; |
27
|
3
|
100
|
|
|
|
15
|
if (ref $real_method eq 'CODE') { |
|
|
50
|
|
|
|
|
|
28
|
1
|
|
|
0
|
|
5
|
*{"$class\::$method"} = sub { $real_method->($plugin, shift, @_) }; |
|
1
|
|
|
|
|
21
|
|
|
0
|
|
|
|
|
0
|
|
29
|
|
|
|
|
|
|
} elsif (!ref($real_method)) { |
30
|
2
|
|
|
2
|
|
15
|
*{"$class\::$method"} = sub { $plugin->$real_method(shift, @_) }; |
|
2
|
|
|
|
|
41
|
|
|
2
|
|
|
|
|
17
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub remove_method { |
36
|
0
|
|
|
0
|
0
|
|
my($self, @methods) = @_; |
37
|
0
|
|
|
|
|
|
$self->NEXT( remove_method => @methods ); |
38
|
0
|
|
|
|
|
|
while (my($method, $plugin) = splice @methods, 0, 2) { |
39
|
4
|
|
|
4
|
|
21
|
no strict 'refs'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
321
|
|
40
|
0
|
|
|
|
|
|
delete ${ref($self) . "::"}{$method}; |
|
0
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |