line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Valiemon::Attributes::Type; |
2
|
17
|
|
|
17
|
|
10000
|
use strict; |
|
17
|
|
|
|
|
37
|
|
|
17
|
|
|
|
|
496
|
|
3
|
17
|
|
|
17
|
|
95
|
use warnings; |
|
17
|
|
|
|
|
40
|
|
|
17
|
|
|
|
|
397
|
|
4
|
17
|
|
|
17
|
|
85
|
use utf8; |
|
17
|
|
|
|
|
45
|
|
|
17
|
|
|
|
|
97
|
|
5
|
17
|
|
|
17
|
|
1912
|
use parent qw(Valiemon::Attributes); |
|
17
|
|
|
|
|
920
|
|
|
17
|
|
|
|
|
108
|
|
6
|
|
|
|
|
|
|
|
7
|
17
|
|
|
17
|
|
4730
|
use List::MoreUtils qw(any); |
|
17
|
|
|
|
|
73946
|
|
|
17
|
|
|
|
|
135
|
|
8
|
|
|
|
|
|
|
|
9
|
445
|
|
|
445
|
0
|
1385
|
sub attr_name { 'type' } |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub is_valid { |
12
|
445
|
|
|
445
|
0
|
1024
|
my ($class, $context, $schema, $data) = @_; |
13
|
|
|
|
|
|
|
$context->in_attr($class, sub { |
14
|
445
|
|
|
445
|
|
802
|
my $types = $schema->{type}; |
15
|
|
|
|
|
|
|
|
16
|
445
|
|
|
|
|
630
|
my $is_valid = do { |
17
|
445
|
100
|
|
|
|
960
|
if (ref $types eq 'ARRAY') { |
18
|
30
|
|
|
|
|
158
|
any { $class->_check($context->prims, $_, $data) } @$types |
|
55
|
|
|
|
|
136
|
|
19
|
|
|
|
|
|
|
} else { |
20
|
415
|
|
|
|
|
1075
|
$class->_check($context->prims, $types, $data); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
}; |
23
|
445
|
|
|
|
|
1140
|
$is_valid; |
24
|
445
|
|
|
|
|
2476
|
}); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _check { |
28
|
470
|
|
|
470
|
|
1410
|
my ($class, $prims, $type, $data) = @_; |
29
|
470
|
|
|
|
|
1004
|
my $method = 'is_' . $type; |
30
|
470
|
100
|
100
|
|
|
2594
|
$prims->can($method) && $prims->$method($data) ? 1 : 0; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |