line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#line 1 |
2
|
6
|
|
|
6
|
|
42
|
package Test2::Util::ExternalMeta; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
167
|
|
3
|
6
|
|
|
6
|
|
31
|
use strict; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
252
|
|
4
|
|
|
|
|
|
|
use warnings; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.302073'; |
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
6
|
|
33
|
|
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
633
|
|
9
|
|
|
|
|
|
|
use Carp qw/croak/; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub META_KEY() { '_meta' } |
12
|
|
|
|
|
|
|
|
13
|
6
|
|
|
6
|
|
41
|
our @EXPORT = qw/meta set_meta get_meta delete_meta/; |
|
6
|
|
|
|
|
2335
|
|
14
|
|
|
|
|
|
|
BEGIN { require Exporter; our @ISA = qw(Exporter) } |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
0
|
1
|
0
|
sub set_meta { |
17
|
0
|
|
|
|
|
0
|
my $self = shift; |
18
|
|
|
|
|
|
|
my ($key, $value) = @_; |
19
|
0
|
|
|
|
|
0
|
|
20
|
|
|
|
|
|
|
validate_key($key); |
21
|
0
|
|
0
|
|
|
0
|
|
22
|
0
|
|
|
|
|
0
|
$self->{+META_KEY} ||= {}; |
23
|
|
|
|
|
|
|
$self->{+META_KEY}->{$key} = $value; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
0
|
1
|
0
|
sub get_meta { |
27
|
0
|
|
|
|
|
0
|
my $self = shift; |
28
|
|
|
|
|
|
|
my ($key) = @_; |
29
|
0
|
|
|
|
|
0
|
|
30
|
|
|
|
|
|
|
validate_key($key); |
31
|
0
|
0
|
|
|
|
0
|
|
32
|
0
|
|
|
|
|
0
|
my $meta = $self->{+META_KEY} or return undef; |
33
|
|
|
|
|
|
|
return $meta->{$key}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
0
|
1
|
0
|
sub delete_meta { |
37
|
0
|
|
|
|
|
0
|
my $self = shift; |
38
|
|
|
|
|
|
|
my ($key) = @_; |
39
|
0
|
|
|
|
|
0
|
|
40
|
|
|
|
|
|
|
validate_key($key); |
41
|
0
|
0
|
|
|
|
0
|
|
42
|
0
|
|
|
|
|
0
|
my $meta = $self->{+META_KEY} or return undef; |
43
|
|
|
|
|
|
|
delete $meta->{$key}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
71
|
|
|
71
|
1
|
141
|
sub meta { |
47
|
71
|
|
|
|
|
152
|
my $self = shift; |
48
|
|
|
|
|
|
|
my ($key, $default) = @_; |
49
|
71
|
|
|
|
|
210
|
|
50
|
|
|
|
|
|
|
validate_key($key); |
51
|
71
|
|
|
|
|
153
|
|
52
|
71
|
50
|
66
|
|
|
250
|
my $meta = $self->{+META_KEY}; |
53
|
|
|
|
|
|
|
return undef unless $meta || defined($default); |
54
|
71
|
100
|
|
|
|
155
|
|
55
|
15
|
|
|
|
|
31
|
unless($meta) { |
56
|
15
|
|
|
|
|
46
|
$meta = {}; |
57
|
|
|
|
|
|
|
$self->{+META_KEY} = $meta; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
71
|
100
|
66
|
|
|
288
|
$meta->{$key} = $default |
61
|
|
|
|
|
|
|
if defined($default) && !defined($meta->{$key}); |
62
|
71
|
|
|
|
|
210
|
|
63
|
|
|
|
|
|
|
return $meta->{$key}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
71
|
|
|
71
|
0
|
109
|
sub validate_key { |
67
|
|
|
|
|
|
|
my $key = shift; |
68
|
71
|
50
|
33
|
|
|
304
|
|
69
|
|
|
|
|
|
|
return if $key && !ref($key); |
70
|
0
|
0
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my $render_key = defined($key) ? "'$key'" : 'undef'; |
72
|
|
|
|
|
|
|
croak "Invalid META key: $render_key, keys must be true, and may not be references"; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |