| 1 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | package Data::Rx::CoreType::any; | ||||||||||||||||||||||||||||
| 4 | # ABSTRACT: the Rx //any type | ||||||||||||||||||||||||||||
| 5 | 1 | $Data::Rx::CoreType::any::VERSION = '0.200007'; | |||||||||||||||||||||||||||
| 6 | 1 | ▶ | use parent 'Data::Rx::CoreType'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | sub guts_from_arg { | ||||||||||||||||||||||||||||
| 11 | 5 | ▶ | my ($class, $arg, $rx, $type) = @_; | ||||||||||||||||||||||||||
|
Subroutine
guts_from_arg: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 5 | ▶ | Carp::croak("unknown arguments to new") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 14 | unless Data::Rx::Util->_x_subset_keys_y($arg, { of => 1}); | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 5 | my $guts = {}; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 5 | ▶ | if (my $of = $arg->{of}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | 2 | ▶ | Carp::croak("invalid 'of' argument to //any") unless | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::reftype($of) eq "ARRAY" and @$of
MC/DC50%1/2
builtin::reftype($of) eq "ARRAY" and @$of
builtin::reftype($of) eq "ARRAY"
@$of
Truth table66%2/3
A and B
A= builtin::reftype($of) eq "ARRAY"B= @$of
| |||||||||||||||||||||||||||||
| 20 | Scalar::Util::reftype $of eq 'ARRAY' and @$of; | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 1 | $guts->{of} = [ map {; $rx->make_schema($_) } @$of ]; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 4 | return $guts; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | sub assert_valid { | ||||||||||||||||||||||||||||
| 29 | 120 | ▶ | return 1 unless $_[0]->{of}; | ||||||||||||||||||||||||||
|
Subroutine
assert_valid: called CC=4 SCAR=13.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 54 | my ($self, $value) = @_; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 54 | my @failures; | |||||||||||||||||||||||||||
| 34 | 54 | for my $i (0 .. $#{ $self->{of} }) { | |||||||||||||||||||||||||||
| 35 | 106 | my $check = $self->{of}[ $i ]; | |||||||||||||||||||||||||||
| 36 | 106 | ▶ | return 1 if eval { $check->assert_valid($value) }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 103 | my $failure = $@; | |||||||||||||||||||||||||||
| 39 | 103 | $failure->contextualize({ | |||||||||||||||||||||||||||
| 40 | type => $self->type, | ||||||||||||||||||||||||||||
| 41 | check_path => [ [ 'of', 'key'], [ $i, 'index' ] ], | ||||||||||||||||||||||||||||
| 42 | }); | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 103 | push @failures, $failure; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | $self->fail({ | ||||||||||||||||||||||||||||
| 48 | 51 | error => [ qw(none) ], | |||||||||||||||||||||||||||
| 49 | message => "matched none of the available alternatives", | ||||||||||||||||||||||||||||
| 50 | value => $value, | ||||||||||||||||||||||||||||
| 51 | failures => \@failures, | ||||||||||||||||||||||||||||
| 52 | }); | ||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 54 | ▶ | sub subname { 'any' } | ||||||||||||||||||||||||||
|
Subroutine
subname: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 1 | 1; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | __END__ | ||||||||||||||||||||||||||||