Valiant/Proxy/Hash.pm

filter: Statementstmt 61.5% 8 / 13 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 2 / 4 Podpod 0.0% 0 / 3 totaltotal 50.0% 11 / 22 CC 2 SCAR 6.2
CC
2
Cov
60%
read_attribute_for_validation
2.1
keys
2.0
values
2.0
CRAP 1.9
« Valiant/HTML/Util/Collection.pm ↑ Summary Valiant/JSON/Util.pm »
1 package Valiant::Proxy::Hash;
2  
3 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 with 'Valiant::Proxy';
5  
6 sub read_attribute_for_validation {
7 27 ▶ my ($self, $attribute) = @_;
Subroutine read_attribute_for_validation: called CC=2 SCAR=7.6
Pod undocumented
8 27 ▶ if(exists $self->for->{$attribute}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->for->{$attribute}) { } 27 0 27
9 27 return $self->for->{$attribute};
10 } else {
11 0 return undef; # TODO Might need a flag to allow die here?
12 }
13 }
14  
15 0 ▶sub keys { return keys %{ $_[0]->for } }
Subroutine keys: not called CC=1 SCAR=6.9
Pod undocumented
16 0 ▶sub values { return map { $_[0]->for->{$_} } $_[0]->keys }
Subroutine values: not called CC=1 SCAR=6.9
Pod undocumented
17  
18 1 1;
19  
20 =head1 NAME
21  
22 Valiant::Result::Hash - Wrap a hashref in a result object for validation.
23  
24 =head1 SYNOPSIS
25  
26 TBD
27  
28 =head1 DESCRIPTION
29  
30 Allows you to run validations against a HashRef.
31  
32 You probably won't use this directly (although you can) since we have L<Valiant::Class> to
33 encapsulate the most common patterns for this need.
34  
35 =head1 SEE ALSO
36  
37 This does the interface defined by L<Valiant::Proxy> so see the docs on that.
38
39 Also: L<Valiant>, L<Valiant::Validator>, L<Valiant::Validator::Each>.
40  
41 =head1 AUTHOR
42
43 See L<Valiant>
44  
45 =head1 COPYRIGHT & LICENSE
46
47 See L<Valiant>
48  
49 =cut
« Valiant/HTML/Util/Collection.pm ↑ Summary Valiant/JSON/Util.pm »