File Coverage

blib/lib/Dancer2/Plugin/FormValidator/Input.pm
Criterion Covered Total %
statement 28 28 100.0
branch 1 2 50.0
condition n/a
subroutine 10 10 100.0
pod 0 2 0.0
total 39 42 92.8


line stmt bran cond sub pod time code
1              
2             use strict;
3 18     18   89961 use warnings;
  18         58  
  18         484  
4 18     18   95  
  18         30  
  18         382  
5             use Moo;
6 18     18   526 use Storable qw(dclone);
  18         6030  
  18         89  
7 18     18   8866 use Hash::Util qw(lock_hashref);
  18         13613  
  18         1237  
8 18     18   8381 use Types::Standard qw(HashRef);
  18         42259  
  18         117  
9 18     18   2062 use namespace::clean;
  18         87176  
  18         159  
10 18     18   10027  
  18         13799  
  18         120  
11             ### Input ###
12             # Class to isolate and manipulate input HashRef.
13              
14             has _input => (
15             is => 'ro',
16             isa => HashRef,
17             required => 1,
18             init_arg => 'input',
19             );
20              
21             my ($self, %args) = @_;
22              
23 19     19 0 37070 if (my $input = $args{input}) {
24             $args{input} = $self->_clone_and_lock_input($input);
25 19 50       109 }
26 19         79  
27             return \%args;
28             }
29 18         820  
30             return $_[0]->_input;
31             }
32              
33 36     36 0 5256 # Create locked copy.
34             # Copy input to work with isolated HashRef.
35             my $input = dclone($_[1]);
36              
37             # Lock input to prevent accidental modifying.
38             return lock_hashref($input);
39 19     19   1251 }
40              
41             1;