line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#line 1 |
2
|
1
|
|
|
1
|
|
5
|
package Test2::Util::ExternalMeta; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
3
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
4
|
|
|
|
|
|
|
use warnings; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.302073'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
7
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
81
|
|
9
|
|
|
|
|
|
|
use Carp qw/croak/; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub META_KEY() { '_meta' } |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
6
|
our @EXPORT = qw/meta set_meta get_meta delete_meta/; |
|
1
|
|
|
|
|
319
|
|
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
|
2
|
|
|
2
|
1
|
4
|
sub meta { |
47
|
2
|
|
|
|
|
4
|
my $self = shift; |
48
|
|
|
|
|
|
|
my ($key, $default) = @_; |
49
|
2
|
|
|
|
|
7
|
|
50
|
|
|
|
|
|
|
validate_key($key); |
51
|
2
|
|
|
|
|
4
|
|
52
|
2
|
50
|
66
|
|
|
7
|
my $meta = $self->{+META_KEY}; |
53
|
|
|
|
|
|
|
return undef unless $meta || defined($default); |
54
|
2
|
100
|
|
|
|
4
|
|
55
|
1
|
|
|
|
|
2
|
unless($meta) { |
56
|
1
|
|
|
|
|
3
|
$meta = {}; |
57
|
|
|
|
|
|
|
$self->{+META_KEY} = $meta; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
2
|
100
|
66
|
|
|
10
|
$meta->{$key} = $default |
61
|
|
|
|
|
|
|
if defined($default) && !defined($meta->{$key}); |
62
|
2
|
|
|
|
|
8
|
|
63
|
|
|
|
|
|
|
return $meta->{$key}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
2
|
|
|
2
|
0
|
3
|
sub validate_key { |
67
|
|
|
|
|
|
|
my $key = shift; |
68
|
2
|
50
|
33
|
|
|
10
|
|
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__ |