line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Std::Utils; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
158296
|
use version; $VERSION = qv('0.0.3'); |
|
4
|
|
|
|
|
36925
|
|
|
4
|
|
|
|
|
31
|
|
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
372
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
764
|
|
6
|
4
|
|
|
4
|
|
23
|
use strict; |
|
4
|
|
|
|
|
22
|
|
|
4
|
|
|
|
|
110
|
|
7
|
4
|
|
|
4
|
|
22
|
use Carp; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
522
|
|
8
|
4
|
|
|
4
|
|
26
|
use Scalar::Util qw( refaddr ); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1596
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub import { |
11
|
7
|
|
|
7
|
|
54
|
my $caller = caller; |
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
4
|
|
26
|
no strict qw( refs ); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
515
|
|
14
|
7
|
|
|
|
|
15
|
*{ $caller . '::anon_scalar' } = \&anon_scalar; |
|
7
|
|
|
|
|
42
|
|
15
|
7
|
|
|
|
|
12
|
*{ $caller . '::ident' } = \&refaddr; |
|
7
|
|
|
|
|
57
|
|
16
|
7
|
|
|
|
|
15
|
*{ $caller . '::extract_initializers_from' } = \&extract_initializers_from; |
|
7
|
|
|
|
|
7136
|
|
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
1
|
12
|
sub anon_scalar { return \my $scalar; } |
20
|
|
|
|
|
|
|
|
21
|
4
|
|
|
4
|
|
24
|
use List::Util qw( first ); |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
1305
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub extract_initializers_from { |
24
|
4
|
|
|
4
|
1
|
9845
|
my ($arg_ref) = @_; |
25
|
|
|
|
|
|
|
|
26
|
4
|
|
|
|
|
12
|
my $class_name = caller; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Find the class-specific sub-hash (if any)... |
29
|
5
|
|
|
5
|
|
12
|
my $specific_inits_ref |
30
|
4
|
|
|
|
|
42
|
= first {defined $_} $arg_ref->{$class_name}, {}; |
31
|
4
|
100
|
|
|
|
510
|
croak "$class_name initializer must be a nested hash" if ref $specific_inits_ref ne 'HASH'; |
32
|
|
|
|
|
|
|
# Return initializers, overriding general initializers from the top level |
33
|
|
|
|
|
|
|
# with any second-level initializers that are specific to the class.... |
34
|
3
|
|
|
|
|
5
|
return ( %{$arg_ref}, %{$specific_inits_ref} ); |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
24
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
39
|
|
|
|
|
|
|
__END__ |