line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
12
|
use v5.12.0; |
|
1
|
|
|
|
|
3
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
3
|
|
|
|
|
|
|
package Data::Rx::CoreType::map 0.200008; |
4
|
|
|
|
|
|
|
# ABSTRACT: the Rx //map type |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use parent 'Data::Rx::CoreType'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
89
|
use Scalar::Util (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
313
|
|
9
|
|
|
|
|
|
|
|
10
|
70
|
|
|
70
|
0
|
198
|
sub subname { 'map' } |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub guts_from_arg { |
13
|
7
|
|
|
7
|
0
|
23
|
my ($class, $arg, $rx, $type) = @_; |
14
|
|
|
|
|
|
|
|
15
|
7
|
100
|
|
|
|
30
|
Carp::croak("unknown arguments to new") unless |
16
|
|
|
|
|
|
|
Data::Rx::Util->_x_subset_keys_y($arg, { values => 1 }); |
17
|
|
|
|
|
|
|
|
18
|
6
|
100
|
|
|
|
192
|
Carp::croak("no values constraint given") unless $arg->{values}; |
19
|
|
|
|
|
|
|
|
20
|
5
|
|
|
|
|
20
|
return { value_constraint => $rx->make_schema($arg->{values}) }; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub assert_valid { |
24
|
61
|
|
|
61
|
0
|
4740
|
my ($self, $value) = @_; |
25
|
|
|
|
|
|
|
|
26
|
61
|
100
|
100
|
|
|
314
|
unless (! Scalar::Util::blessed($value) and ref $value eq 'HASH') { |
27
|
43
|
|
|
|
|
236
|
$self->fail({ |
28
|
|
|
|
|
|
|
error => [ qw(type) ], |
29
|
|
|
|
|
|
|
message => "found value is not a hashref", |
30
|
|
|
|
|
|
|
value => $value, |
31
|
|
|
|
|
|
|
}); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
18
|
|
|
|
|
32
|
my @subchecks; |
35
|
18
|
50
|
|
|
|
53
|
for my $key ($self->rx->sort_keys ? sort keys %$value : keys %$value) { |
36
|
|
|
|
|
|
|
push @subchecks, [ |
37
|
|
|
|
|
|
|
$value->{ $key }, |
38
|
|
|
|
|
|
|
$self->{value_constraint}, |
39
|
31
|
|
|
|
|
171
|
{ data_path => [ [$key, 'key'] ], |
40
|
|
|
|
|
|
|
check_path => [ ['values', 'key' ] ], |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
]; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
18
|
|
|
|
|
86
|
$self->perform_subchecks(\@subchecks); |
46
|
|
|
|
|
|
|
|
47
|
10
|
|
|
|
|
44
|
return 1; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |