line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FormFu::Role::Element::SingleValueField; |
2
|
|
|
|
|
|
|
|
3
|
99
|
|
|
99
|
|
54328
|
use strict; |
|
99
|
|
|
|
|
199
|
|
|
99
|
|
|
|
|
4375
|
|
4
|
|
|
|
|
|
|
our $VERSION = '2.05'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
99
|
|
|
99
|
|
391
|
use Moose::Role; |
|
99
|
|
|
|
|
141
|
|
|
99
|
|
|
|
|
612
|
|
7
|
|
|
|
|
|
|
|
8
|
99
|
|
|
99
|
|
337429
|
use Carp qw( croak ); |
|
99
|
|
|
|
|
163
|
|
|
99
|
|
|
|
|
58176
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub add_error { |
11
|
7
|
|
|
7
|
0
|
20
|
my ( $self, @errors ) = @_; |
12
|
|
|
|
|
|
|
|
13
|
7
|
|
|
|
|
13
|
push @{ $self->_errors }, @errors; |
|
7
|
|
|
|
|
175
|
|
14
|
|
|
|
|
|
|
|
15
|
7
|
|
|
|
|
21
|
return; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub deflator { |
19
|
11
|
|
|
11
|
0
|
31
|
my ( $self, $arg ) = @_; |
20
|
11
|
|
|
|
|
21
|
my @return; |
21
|
|
|
|
|
|
|
|
22
|
11
|
100
|
|
|
|
49
|
if ( ref $arg eq 'ARRAY' ) { |
23
|
5
|
|
|
|
|
15
|
push @return, map { _single_deflator( $self, $_ ) } @$arg; |
|
5
|
|
|
|
|
18
|
|
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
else { |
26
|
6
|
|
|
|
|
26
|
push @return, _single_deflator( $self, $arg ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
11
|
50
|
|
|
|
65
|
return @return == 1 ? $return[0] : @return; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub filter { |
33
|
7
|
|
|
7
|
0
|
18
|
my ( $self, $arg ) = @_; |
34
|
7
|
|
|
|
|
13
|
my @return; |
35
|
|
|
|
|
|
|
|
36
|
7
|
100
|
|
|
|
31
|
if ( ref $arg eq 'ARRAY' ) { |
37
|
1
|
|
|
|
|
1
|
push @return, map { _single_filter( $self, $_ ) } @$arg; |
|
1
|
|
|
|
|
4
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else { |
40
|
6
|
|
|
|
|
33
|
push @return, _single_filter( $self, $arg ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
7
|
50
|
|
|
|
41
|
return @return == 1 ? $return[0] : @return; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub constraint { |
47
|
12
|
|
|
12
|
0
|
36
|
my ( $self, $arg ) = @_; |
48
|
12
|
|
|
|
|
21
|
my @return; |
49
|
|
|
|
|
|
|
|
50
|
12
|
100
|
|
|
|
53
|
if ( ref $arg eq 'ARRAY' ) { |
51
|
4
|
|
|
|
|
9
|
push @return, map { _single_constraint( $self, $_ ) } @$arg; |
|
5
|
|
|
|
|
16
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
else { |
54
|
8
|
|
|
|
|
32
|
push @return, _single_constraint( $self, $arg ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
12
|
100
|
|
|
|
64
|
return @return == 1 ? $return[0] : @return; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub inflator { |
61
|
13
|
|
|
13
|
0
|
30
|
my ( $self, $arg ) = @_; |
62
|
13
|
|
|
|
|
35
|
my @return; |
63
|
|
|
|
|
|
|
|
64
|
13
|
100
|
|
|
|
86
|
if ( ref $arg eq 'ARRAY' ) { |
65
|
1
|
|
|
|
|
2
|
push @return, map { _single_inflator( $self, $_ ) } @$arg; |
|
1
|
|
|
|
|
4
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
else { |
68
|
12
|
|
|
|
|
54
|
push @return, _single_inflator( $self, $arg ); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
13
|
50
|
|
|
|
75
|
return @return == 1 ? $return[0] : @return; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub validator { |
75
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $arg ) = @_; |
76
|
0
|
|
|
|
|
0
|
my @return; |
77
|
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
0
|
if ( ref $arg eq 'ARRAY' ) { |
79
|
0
|
|
|
|
|
0
|
push @return, map { _single_validator( $self, $_ ) } @$arg; |
|
0
|
|
|
|
|
0
|
|
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
else { |
82
|
0
|
|
|
|
|
0
|
push @return, _single_validator( $self, $arg ); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
0
|
0
|
|
|
|
0
|
return @return == 1 ? $return[0] : @return; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub transformer { |
89
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $arg ) = @_; |
90
|
0
|
|
|
|
|
0
|
my @return; |
91
|
|
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
0
|
if ( ref $arg eq 'ARRAY' ) { |
93
|
0
|
|
|
|
|
0
|
push @return, map { _single_transformer( $self, $_ ) } @$arg; |
|
0
|
|
|
|
|
0
|
|
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
else { |
96
|
0
|
|
|
|
|
0
|
push @return, _single_transformer( $self, $arg ); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
0
|
0
|
|
|
|
0
|
return @return == 1 ? $return[0] : @return; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub plugin { |
103
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $arg ) = @_; |
104
|
0
|
|
|
|
|
0
|
my @return; |
105
|
|
|
|
|
|
|
|
106
|
0
|
0
|
|
|
|
0
|
if ( ref $arg eq 'ARRAY' ) { |
107
|
0
|
|
|
|
|
0
|
push @return, map { _single_plugin( $self, $_ ) } @$arg; |
|
0
|
|
|
|
|
0
|
|
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
else { |
110
|
0
|
|
|
|
|
0
|
push @return, _single_plugin( $self, $arg ); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
0
|
0
|
|
|
|
0
|
return @return == 1 ? $return[0] : @return; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
BEGIN { |
117
|
99
|
|
|
99
|
|
302
|
*constraints = \&constraint; |
118
|
99
|
|
|
|
|
188
|
*filters = \&filter; |
119
|
99
|
|
|
|
|
184
|
*deflators = \&deflator; |
120
|
99
|
|
|
|
|
150
|
*inflators = \&inflator; |
121
|
99
|
|
|
|
|
162
|
*validators = \&validator; |
122
|
99
|
|
|
|
|
145
|
*transformers = \&transformer; |
123
|
99
|
|
|
|
|
53503
|
*plugins = \&plugin; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub _single_deflator { |
127
|
11
|
|
|
11
|
|
17
|
my ( $self, $arg ) = @_; |
128
|
|
|
|
|
|
|
|
129
|
11
|
100
|
|
|
|
52
|
if ( !ref $arg ) { |
|
|
50
|
|
|
|
|
|
130
|
1
|
|
|
|
|
1
|
$arg = { type => $arg }; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
elsif ( ref $arg eq 'HASH' ) { |
133
|
10
|
|
|
|
|
41
|
$arg = {%$arg}; # shallow clone |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
else { |
136
|
0
|
|
|
|
|
0
|
croak 'invalid args'; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
11
|
|
|
|
|
17
|
my @return; |
140
|
|
|
|
|
|
|
|
141
|
11
|
|
|
|
|
25
|
my $type = delete $arg->{type}; |
142
|
|
|
|
|
|
|
|
143
|
11
|
|
|
|
|
358
|
my $new = $self->_require_deflator( $type, $arg ); |
144
|
|
|
|
|
|
|
|
145
|
11
|
|
|
|
|
19
|
push @{ $self->_deflators }, $new; |
|
11
|
|
|
|
|
345
|
|
146
|
|
|
|
|
|
|
|
147
|
11
|
|
|
|
|
48
|
return $new; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub _single_filter { |
151
|
7
|
|
|
7
|
|
10
|
my ( $self, $arg ) = @_; |
152
|
|
|
|
|
|
|
|
153
|
7
|
100
|
|
|
|
33
|
if ( !ref $arg ) { |
|
|
50
|
|
|
|
|
|
154
|
1
|
|
|
|
|
2
|
$arg = { type => $arg }; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
elsif ( ref $arg eq 'HASH' ) { |
157
|
6
|
|
|
|
|
25
|
$arg = {%$arg}; # shallow clone |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
else { |
160
|
0
|
|
|
|
|
0
|
croak 'invalid args'; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
7
|
|
|
|
|
11
|
my @return; |
164
|
|
|
|
|
|
|
|
165
|
7
|
|
|
|
|
15
|
my $type = delete $arg->{type}; |
166
|
|
|
|
|
|
|
|
167
|
7
|
|
|
|
|
308
|
my $new = $self->_require_filter( $type, $arg ); |
168
|
|
|
|
|
|
|
|
169
|
7
|
|
|
|
|
14
|
push @{ $self->_filters }, $new; |
|
7
|
|
|
|
|
213
|
|
170
|
|
|
|
|
|
|
|
171
|
7
|
|
|
|
|
27
|
return $new; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub _single_constraint { |
175
|
13
|
|
|
13
|
|
21
|
my ( $self, $arg ) = @_; |
176
|
|
|
|
|
|
|
|
177
|
13
|
100
|
|
|
|
46
|
if ( !ref $arg ) { |
|
|
50
|
|
|
|
|
|
178
|
11
|
|
|
|
|
38
|
$arg = { type => $arg }; |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
elsif ( ref $arg eq 'HASH' ) { |
181
|
2
|
|
|
|
|
6
|
$arg = {%$arg}; # shallow clone |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
else { |
184
|
0
|
|
|
|
|
0
|
croak 'invalid args'; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
13
|
|
|
|
|
18
|
my @return; |
188
|
|
|
|
|
|
|
|
189
|
13
|
|
|
|
|
30
|
my $type = delete $arg->{type}; |
190
|
|
|
|
|
|
|
|
191
|
13
|
|
|
|
|
146
|
my $new = $self->_require_constraint( $type, $arg ); |
192
|
|
|
|
|
|
|
|
193
|
13
|
|
|
|
|
23
|
push @{ $self->_constraints }, $new; |
|
13
|
|
|
|
|
384
|
|
194
|
|
|
|
|
|
|
|
195
|
13
|
|
|
|
|
47
|
return $new; |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub _single_inflator { |
199
|
13
|
|
|
13
|
|
24
|
my ( $self, $arg ) = @_; |
200
|
|
|
|
|
|
|
|
201
|
13
|
50
|
|
|
|
65
|
if ( !ref $arg ) { |
|
|
50
|
|
|
|
|
|
202
|
0
|
|
|
|
|
0
|
$arg = { type => $arg }; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
elsif ( ref $arg eq 'HASH' ) { |
205
|
13
|
|
|
|
|
53
|
$arg = {%$arg}; # shallow clone |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
else { |
208
|
0
|
|
|
|
|
0
|
croak 'invalid args'; |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
13
|
|
|
|
|
24
|
my @return; |
212
|
|
|
|
|
|
|
|
213
|
13
|
|
|
|
|
31
|
my $type = delete $arg->{type}; |
214
|
|
|
|
|
|
|
|
215
|
13
|
|
|
|
|
227
|
my $new = $self->_require_inflator( $type, $arg ); |
216
|
|
|
|
|
|
|
|
217
|
13
|
|
|
|
|
28
|
push @{ $self->_inflators }, $new; |
|
13
|
|
|
|
|
421
|
|
218
|
|
|
|
|
|
|
|
219
|
13
|
|
|
|
|
51
|
return $new; |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub _single_validator { |
223
|
0
|
|
|
0
|
|
|
my ( $self, $arg ) = @_; |
224
|
|
|
|
|
|
|
|
225
|
0
|
0
|
|
|
|
|
if ( !ref $arg ) { |
|
|
0
|
|
|
|
|
|
226
|
0
|
|
|
|
|
|
$arg = { type => $arg }; |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
elsif ( ref $arg eq 'HASH' ) { |
229
|
0
|
|
|
|
|
|
$arg = {%$arg}; # shallow clone |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
else { |
232
|
0
|
|
|
|
|
|
croak 'invalid args'; |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
0
|
|
|
|
|
|
my @return; |
236
|
|
|
|
|
|
|
|
237
|
0
|
|
|
|
|
|
my $type = delete $arg->{type}; |
238
|
|
|
|
|
|
|
|
239
|
0
|
|
|
|
|
|
my $new = $self->_require_validator( $type, $arg ); |
240
|
|
|
|
|
|
|
|
241
|
0
|
|
|
|
|
|
push @{ $self->_validators }, $new; |
|
0
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
|
243
|
0
|
|
|
|
|
|
return $new; |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
sub _single_transformer { |
247
|
0
|
|
|
0
|
|
|
my ( $self, $arg ) = @_; |
248
|
|
|
|
|
|
|
|
249
|
0
|
0
|
|
|
|
|
if ( !ref $arg ) { |
|
|
0
|
|
|
|
|
|
250
|
0
|
|
|
|
|
|
$arg = { type => $arg }; |
251
|
|
|
|
|
|
|
} |
252
|
|
|
|
|
|
|
elsif ( ref $arg eq 'HASH' ) { |
253
|
0
|
|
|
|
|
|
$arg = {%$arg}; # shallow clone |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
else { |
256
|
0
|
|
|
|
|
|
croak 'invalid args'; |
257
|
|
|
|
|
|
|
} |
258
|
|
|
|
|
|
|
|
259
|
0
|
|
|
|
|
|
my @return; |
260
|
|
|
|
|
|
|
|
261
|
0
|
|
|
|
|
|
my $type = delete $arg->{type}; |
262
|
|
|
|
|
|
|
|
263
|
0
|
|
|
|
|
|
my $new = $self->_require_transformer( $type, $arg ); |
264
|
|
|
|
|
|
|
|
265
|
0
|
|
|
|
|
|
push @{ $self->_transformers }, $new; |
|
0
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
|
267
|
0
|
|
|
|
|
|
return $new; |
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
sub _single_plugin { |
271
|
0
|
|
|
0
|
|
|
my ( $self, $arg ) = @_; |
272
|
|
|
|
|
|
|
|
273
|
0
|
0
|
|
|
|
|
if ( !ref $arg ) { |
|
|
0
|
|
|
|
|
|
274
|
0
|
|
|
|
|
|
$arg = { type => $arg }; |
275
|
|
|
|
|
|
|
} |
276
|
|
|
|
|
|
|
elsif ( ref $arg eq 'HASH' ) { |
277
|
0
|
|
|
|
|
|
$arg = {%$arg}; # shallow clone |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
else { |
280
|
0
|
|
|
|
|
|
croak 'invalid args'; |
281
|
|
|
|
|
|
|
} |
282
|
|
|
|
|
|
|
|
283
|
0
|
|
|
|
|
|
my @return; |
284
|
|
|
|
|
|
|
|
285
|
0
|
|
|
|
|
|
my $type = delete $arg->{type}; |
286
|
|
|
|
|
|
|
|
287
|
0
|
|
|
|
|
|
my $new = $self->_require_plugin( $type, $arg ); |
288
|
|
|
|
|
|
|
|
289
|
0
|
|
|
|
|
|
push @{ $self->_plugins }, $new; |
|
0
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
|
291
|
0
|
|
|
|
|
|
return $new; |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
1; |