line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Valiemon::Attributes::Type; |
2
|
13
|
|
|
13
|
|
13140
|
use strict; |
|
13
|
|
|
|
|
21
|
|
|
13
|
|
|
|
|
481
|
|
3
|
13
|
|
|
13
|
|
67
|
use warnings; |
|
13
|
|
|
|
|
36
|
|
|
13
|
|
|
|
|
618
|
|
4
|
13
|
|
|
13
|
|
64
|
use utf8; |
|
13
|
|
|
|
|
20
|
|
|
13
|
|
|
|
|
88
|
|
5
|
13
|
|
|
13
|
|
1656
|
use parent qw(Valiemon::Attributes); |
|
13
|
|
|
|
|
803
|
|
|
13
|
|
|
|
|
88
|
|
6
|
|
|
|
|
|
|
|
7
|
13
|
|
|
13
|
|
8252
|
use List::MoreUtils qw(any); |
|
13
|
|
|
|
|
97108
|
|
|
13
|
|
|
|
|
118
|
|
8
|
|
|
|
|
|
|
|
9
|
161
|
|
|
161
|
0
|
720
|
sub attr_name { 'type' } |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub is_valid { |
12
|
161
|
|
|
161
|
0
|
656
|
my ($class, $context, $schema, $data) = @_; |
13
|
|
|
|
|
|
|
$context->in_attr($class, sub { |
14
|
161
|
|
|
161
|
|
291
|
my $types = $schema->{type}; |
15
|
|
|
|
|
|
|
|
16
|
161
|
|
|
|
|
157
|
my $is_valid = do { |
17
|
161
|
50
|
|
|
|
401
|
if (ref $types eq 'ARRAY') { |
18
|
0
|
|
|
|
|
0
|
any { $class->_check($context->prims, $_, $data) } @$types |
|
0
|
|
|
|
|
0
|
|
19
|
|
|
|
|
|
|
} else { |
20
|
161
|
|
|
|
|
462
|
$class->_check($context->prims, $types, $data); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
}; |
23
|
161
|
|
|
|
|
453
|
$is_valid; |
24
|
161
|
|
|
|
|
1147
|
}); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _check { |
28
|
161
|
|
|
161
|
|
277
|
my ($class, $prims, $type, $data) = @_; |
29
|
161
|
|
|
|
|
329
|
my $method = 'is_' . $type; |
30
|
161
|
100
|
66
|
|
|
1295
|
$prims->can($method) && $prims->$method($data) ? 1 : 0; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |