line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Valiemon::Attributes::Type; |
2
|
18
|
|
|
18
|
|
7475
|
use strict; |
|
18
|
|
|
|
|
21
|
|
|
18
|
|
|
|
|
423
|
|
3
|
18
|
|
|
18
|
|
52
|
use warnings; |
|
18
|
|
|
|
|
18
|
|
|
18
|
|
|
|
|
314
|
|
4
|
18
|
|
|
18
|
|
47
|
use utf8; |
|
18
|
|
|
|
|
17
|
|
|
18
|
|
|
|
|
61
|
|
5
|
18
|
|
|
18
|
|
711
|
use parent qw(Valiemon::Attributes); |
|
18
|
|
|
|
|
274
|
|
|
18
|
|
|
|
|
60
|
|
6
|
|
|
|
|
|
|
|
7
|
18
|
|
|
18
|
|
3347
|
use List::MoreUtils qw(any); |
|
18
|
|
|
|
|
46070
|
|
|
18
|
|
|
|
|
110
|
|
8
|
|
|
|
|
|
|
|
9
|
438
|
|
|
438
|
0
|
780
|
sub attr_name { 'type' } |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub is_valid { |
12
|
438
|
|
|
438
|
0
|
587
|
my ($class, $context, $schema, $data) = @_; |
13
|
|
|
|
|
|
|
$context->in_attr($class, sub { |
14
|
438
|
|
|
438
|
|
445
|
my $types = $schema->{type}; |
15
|
|
|
|
|
|
|
|
16
|
438
|
|
|
|
|
294
|
my $is_valid = do { |
17
|
438
|
100
|
|
|
|
606
|
if (ref $types eq 'ARRAY') { |
18
|
30
|
|
|
|
|
104
|
any { $class->_check($context->prims, $_, $data) } @$types |
|
55
|
|
|
|
|
93
|
|
19
|
|
|
|
|
|
|
} else { |
20
|
408
|
|
|
|
|
750
|
$class->_check($context->prims, $types, $data); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
}; |
23
|
438
|
|
|
|
|
850
|
$is_valid; |
24
|
438
|
|
|
|
|
1707
|
}); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _check { |
28
|
463
|
|
|
463
|
|
454
|
my ($class, $prims, $type, $data) = @_; |
29
|
463
|
|
|
|
|
540
|
my $method = 'is_' . $type; |
30
|
463
|
100
|
100
|
|
|
1920
|
$prims->can($method) && $prims->$method($data) ? 1 : 0; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |