line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Implant; |
2
|
|
|
|
|
|
|
# ABSTRACT: Manipulating mixin and inheritance out of packages |
3
|
|
|
|
|
|
|
|
4
|
4
|
|
|
4
|
|
124450
|
use 5.008008; |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
146
|
|
5
|
4
|
|
|
4
|
|
21
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
122
|
|
6
|
4
|
|
|
4
|
|
19
|
no strict "refs"; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
118
|
|
7
|
4
|
|
|
4
|
|
24
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
116
|
|
8
|
4
|
|
|
4
|
|
3600
|
use Class::Inspector; |
|
4
|
|
|
|
|
16927
|
|
|
4
|
|
|
|
|
1373
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub import { |
13
|
4
|
|
|
4
|
|
32
|
*{(caller)[0] . "::implant"} = \&implant; |
|
4
|
|
|
|
|
6519
|
|
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub implant (@) { |
17
|
3
|
100
|
|
3
|
0
|
40
|
my $option = ( ref($_[-1]) eq "HASH" ? pop(@_) : undef ); |
18
|
3
|
|
|
|
|
11
|
my @class = @_; |
19
|
|
|
|
|
|
|
|
20
|
3
|
|
|
|
|
13
|
my $target = caller; |
21
|
|
|
|
|
|
|
|
22
|
3
|
100
|
|
|
|
17
|
if (defined($option)) { |
23
|
2
|
100
|
|
|
|
8
|
$target = $option->{into} if defined($option->{into}); |
24
|
2
|
100
|
|
1
|
|
103
|
eval qq{ package $target; use base qw(@class); } if $option->{inherit}; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
97
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
3
|
|
|
|
|
11
|
for my $class (reverse @class) { |
28
|
3
|
|
|
|
|
8
|
for my $function (@{ _get_methods($class) }) { |
|
3
|
|
|
|
|
14
|
|
29
|
6
|
|
|
|
|
274
|
*{ $target . "::" . $function } = \&{ $class . "::" . $function }; |
|
6
|
|
|
|
|
53
|
|
|
6
|
|
|
|
|
20
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
3
|
|
|
3
|
|
33
|
sub _get_methods { Class::Inspector->functions(shift) } |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |