line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::MixinFactory::InsideOutAttr; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
43
|
use strict; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
684
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
######################################################################## |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub import { |
8
|
16
|
|
|
16
|
|
30
|
my $methodmaker = shift; |
9
|
16
|
|
|
|
|
56
|
my $target_class = ( caller )[0]; |
10
|
8
|
|
|
8
|
|
40
|
no strict 'refs'; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
2621
|
|
11
|
16
|
|
|
|
|
42
|
foreach my $attr ( @_ ) { |
12
|
32
|
|
|
276
|
|
302
|
*{ $target_class . '::' . $attr } = sub { inside_out( $attr, @_ ) } |
|
276
|
|
|
|
|
615
|
|
13
|
32
|
|
|
|
|
135
|
} |
14
|
16
|
|
|
|
|
1160
|
defined *{ $target_class . '::' . 'DESTROY' }{CODE} |
|
16
|
|
|
|
|
200
|
|
15
|
16
|
50
|
|
|
|
25
|
or *{ $target_class . '::' . 'DESTROY' } = \&destroy; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my %inside_out; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub inside_out { |
21
|
276
|
|
|
276
|
0
|
315
|
my $callee = shift; |
22
|
276
|
|
|
|
|
289
|
my $key = shift; |
23
|
276
|
50
|
|
|
|
735
|
if ( $key eq 'DESTROY' ) { |
|
|
100
|
|
|
|
|
|
24
|
0
|
|
|
|
|
0
|
delete $inside_out{ $callee }; |
25
|
|
|
|
|
|
|
} elsif ( ! scalar @_ ) { |
26
|
261
|
|
|
|
|
1417
|
$inside_out{ $callee }{ $key } |
27
|
|
|
|
|
|
|
} else { |
28
|
15
|
|
|
|
|
967
|
$inside_out{ $callee }{ $key } = shift; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub destroy { |
33
|
2
|
|
|
2
|
0
|
967
|
my $callee = shift; |
34
|
2
|
|
|
|
|
209
|
delete $inside_out{ $callee }; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
######################################################################## |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |