| 1 | package Dancer2::Plugin::FormValidator::Input; | ||||||||||
| 2 | |||||||||||
| 3 | 18 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 18 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 18 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 18 | ▶ | use Storable qw(dclone); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 18 | ▶ | use Hash::Util qw(lock_hashref); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 18 | ▶ | use Types::Standard qw(HashRef); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 18 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | ### Input ### | ||||||||||
| 13 | # Class to isolate and manipulate input HashRef. | ||||||||||
| 14 | |||||||||||
| 15 | 18 | has _input => ( | |||||||||
| 16 | is => 'ro', | ||||||||||
| 17 | isa => HashRef, | ||||||||||
| 18 | required => 1, | ||||||||||
| 19 | init_arg => 'input', | ||||||||||
| 20 | ); | ||||||||||
| 21 | |||||||||||
| 22 | sub BUILDARGS { | ||||||||||
| 23 | 19 | ▶ | my ($self, %args) = @_; | ||||||||
|
Subroutine
BUILDARGS: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 24 | |||||||||||
| 25 | 19 | ▶ | if (my $input = $args{input}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 19 | $args{input} = $self->_clone_and_lock_input($input); | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 18 | return \%args; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | sub get { | ||||||||||
| 33 | 36 | ▶ | return $_[0]->_input; | ||||||||
|
Subroutine
get: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | # Create locked copy. | ||||||||||
| 37 | sub _clone_and_lock_input { | ||||||||||
| 38 | # Copy input to work with isolated HashRef. | ||||||||||
| 39 | 19 | ▶ | my $input = dclone($_[1]); | ||||||||
|
Subroutine
_clone_and_lock_input: called CC=1 SCAR=0.0
| |||||||||||
| 40 | |||||||||||
| 41 | # Lock input to prevent accidental modifying. | ||||||||||
| 42 | 19 | return lock_hashref($input); | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 18 | 1; | |||||||||