line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::PivotalTracker::PropertyAttributes; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.12'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use Scalar::Util qw( blessed ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
9
|
1
|
|
|
1
|
|
6
|
use Sub::Quote qw( quote_sub ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
41
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
7
|
use Exporter qw( import ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
293
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
## no critic (Modules::ProhibitAutomaticExportation) |
14
|
|
|
|
|
|
|
our @EXPORT = 'props_to_attributes'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub props_to_attributes { |
17
|
8
|
|
|
8
|
0
|
4415
|
my %props = @_; |
18
|
|
|
|
|
|
|
|
19
|
8
|
|
|
|
|
24
|
my $caller = caller(); |
20
|
8
|
|
|
|
|
37
|
return map { [ $_ => _attr_for( $caller, $_, $props{$_} ) ] } keys %props; |
|
99
|
|
|
|
|
9487
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _attr_for { |
24
|
99
|
|
|
99
|
|
168
|
my $caller = shift; |
25
|
99
|
|
|
|
|
131
|
my $name = shift; |
26
|
99
|
|
|
|
|
126
|
my $prop = shift; |
27
|
|
|
|
|
|
|
|
28
|
99
|
100
|
|
|
|
312
|
$prop = { type => $prop } |
29
|
|
|
|
|
|
|
if blessed $prop; |
30
|
|
|
|
|
|
|
|
31
|
99
|
|
|
|
|
156
|
my $default = q{}; |
32
|
99
|
|
|
|
|
122
|
my %env; |
33
|
99
|
100
|
|
|
|
180
|
if ( $prop->{may_require_refresh} ) { |
34
|
1
|
|
|
|
|
4
|
$default .= sprintf( <<'EOF', $name ); |
35
|
|
|
|
|
|
|
$_[0]->_refresh_raw_content unless exists $_[0]->raw_content->{%s}; |
36
|
|
|
|
|
|
|
EOF |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
99
|
100
|
|
|
|
167
|
if ( $prop->{default} ) { |
40
|
2
|
|
|
|
|
6
|
$env{'$default'} = \$prop->{default}; |
41
|
2
|
|
|
|
|
8
|
$default .= sprintf( <<'EOF', $name, $name ); |
42
|
|
|
|
|
|
|
my $val = exists $_[0]->raw_content->{%s} ? $_[0]->raw_content->{%s} : $default->(); |
43
|
|
|
|
|
|
|
EOF |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
else { |
46
|
97
|
|
|
|
|
314
|
$default .= sprintf( <<'EOF', $name ); |
47
|
|
|
|
|
|
|
my $val = $_[0]->raw_content->{%s}; |
48
|
|
|
|
|
|
|
EOF |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
99
|
100
|
|
|
|
185
|
if ( $prop->{inflator} ) { |
52
|
21
|
|
|
|
|
57
|
$default .= sprintf( <<'EOF', $prop->{inflator} ); |
53
|
|
|
|
|
|
|
return unless defined $val; |
54
|
|
|
|
|
|
|
return $_[0]->%s( $val ); |
55
|
|
|
|
|
|
|
EOF |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
else { |
58
|
78
|
|
|
|
|
125
|
$default .= 'return $val;'; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
99
|
|
|
|
|
251
|
my $subname = join '::', $caller, '_build_' . $name; |
62
|
|
|
|
|
|
|
return ( |
63
|
|
|
|
|
|
|
is => 'ro', |
64
|
|
|
|
|
|
|
isa => $prop->{type}, |
65
|
99
|
|
|
|
|
236
|
init_arg => undef, |
66
|
|
|
|
|
|
|
lazy => 1, |
67
|
|
|
|
|
|
|
default => quote_sub( $subname, $default, \%env ), |
68
|
|
|
|
|
|
|
clearer => '_clear_' . $name, |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# ABSTRACT: An internal tool; nothing to see here, move along |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=pod |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=encoding UTF-8 |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 NAME |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
WebService::PivotalTracker::PropertyAttributes - An internal tool; nothing to see here, move along |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 VERSION |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
version 0.12 |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 DESCRIPTION |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This package has no user-facing parts. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=for Pod::Coverage *EVERYTHING* |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SUPPORT |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Bugs may be submitted through L<https://github.com/maxmind/WebService-PivotalTracker/issues>. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 AUTHOR |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This software is Copyright (c) 2016 - 2020 by MaxMind, Inc. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This is free software, licensed under: |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
__END__ |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
__END__ |
115
|
|
|
|
|
|
|
|