line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Implant; |
2
|
|
|
|
|
|
|
our $VERSION = '0.02_02'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# ABSTRACT: Manipulating mixin and inheritance out of packages |
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
124711
|
use 5.008008; |
|
5
|
|
|
|
|
18
|
|
|
5
|
|
|
|
|
177
|
|
7
|
5
|
|
|
5
|
|
75
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
146
|
|
8
|
5
|
|
|
5
|
|
23
|
no strict "refs"; |
|
5
|
|
|
|
|
24
|
|
|
5
|
|
|
|
|
117
|
|
9
|
5
|
|
|
5
|
|
26
|
use warnings; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
147
|
|
10
|
5
|
|
|
5
|
|
5054
|
use Class::Inspector; |
|
5
|
|
|
|
|
22506
|
|
|
5
|
|
|
|
|
1621
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub import { |
13
|
5
|
|
|
5
|
|
39
|
*{(caller)[0] . "::implant"} = \&implant; |
|
5
|
|
|
|
|
6056
|
|
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub implant (@) { |
18
|
4
|
100
|
|
4
|
0
|
64
|
my $option = ( ref($_[-1]) eq "HASH" ? pop(@_) : undef ); |
19
|
4
|
|
|
|
|
17
|
my @class = @_; |
20
|
|
|
|
|
|
|
|
21
|
4
|
|
|
|
|
17
|
my $target = caller; |
22
|
|
|
|
|
|
|
|
23
|
4
|
100
|
|
|
|
21
|
if (defined($option)) { |
24
|
|
|
|
|
|
|
# options preprocessing |
25
|
|
|
|
|
|
|
|
26
|
3
|
100
|
|
|
|
23
|
$target = $option->{into} if defined($option->{into}); |
27
|
3
|
100
|
|
1
|
|
163
|
eval qq{ package $target; use base qw(@class); } if $option->{inherit}; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
122
|
|
28
|
|
|
|
|
|
|
|
29
|
3
|
50
|
|
|
|
18
|
if (defined($option->{spec})) { |
30
|
0
|
|
|
|
|
0
|
for (qw(match include exclude)) { |
31
|
0
|
|
|
|
|
0
|
$option->{$_} = undef; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
4
|
|
|
|
|
13
|
for my $class (reverse @class) { |
39
|
|
|
|
|
|
|
|
40
|
7
|
|
|
|
|
13
|
my @methods = @{ get_methods($class) }; |
|
7
|
|
|
|
|
25
|
|
41
|
7
|
100
|
|
|
|
592
|
@methods = grep /$option->{match}/, @methods if $option->{match}; |
42
|
|
|
|
|
|
|
|
43
|
7
|
|
|
|
|
20
|
for my $function (@methods) { |
44
|
13
|
|
|
|
|
19
|
*{ $target . "::" . $function } = \&{ $class . "::" . $function }; |
|
13
|
|
|
|
|
100
|
|
|
13
|
|
|
|
|
42
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
7
|
|
|
7
|
0
|
97
|
sub get_methods { Class::Inspector->functions(shift) } |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |