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