FormHandler/Field/Compound.pm

filter: Statementstmt 98.0% 50 / 51 Branchbran 66.6% 8 / 12 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 2 totaltotal 86.7% 72 / 83 CC 10 SCAR 11.4
CC
10
Cov
90%
test_validate_field
5.4
__ANON__
3.0
__ANON__
3.0
CRAP 3.1
« FormHandler/TraitFor/I18N.pm ↑ Summary FormHandler/Moose.pm »
1 package HTML::FormHandler::Field::Compound;
2 # ABSTRACT: field consisting of subfields
3 56 $HTML::FormHandler::Field::Compound::VERSION = '0.410002';
4 56 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 56 extends 'HTML::FormHandler::Field';
6 56 with 'HTML::FormHandler::Fields';
7 56 with 'HTML::FormHandler::BuildFields';
8 56 with 'HTML::FormHandler::InitResult';
9  
10  
11 56 has '+widget' => ( default => 'Compound' );
12 56 has 'is_compound' => ( is => 'ro', isa => 'Bool', default => 1 );
13 56 has 'item' => ( is => 'rw', clearer => 'clear_item' );
14 56 has '+do_wrapper' => ( default => 0 );
15 56 has '+do_label' => ( default => 0 );
16 56 has 'primary_key' => ( is => 'rw', isa => 'ArrayRef',
17 predicate => 'has_primary_key', );
18  
19 has '+field_name_space' => (
20 20 ▶ default => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
21 20 my $self = shift;
22 20 ▶ return $self->form->field_name_space
Branch: 1 branch
BranchTrueFalseTotal
if $self->form and $self->form->field_name_space 15 5 20
Condition66%2/3
$self->form and $self->form->field_name_space
!ll&&!rl&&r
5015
MC/DC50%1/2
$self->form and $self->form->field_name_space
$self->form $self->form->field_name_space
Truth table66%2/3
A and B
A= $self->formB= $self->form->field_name_space
ABresult
0X0
100
111
23 if $self->form && $self->form->field_name_space;
24 5 return [];
25 },
26 56 );
27  
28 149 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
29 149 my $self = shift;
30 149 $self->_build_fields;
31 }
32  
33 # this is for testing compound fields outside
34 # of a form
35 3 ▶sub test_validate_field {
Subroutine test_validate_field: called CC=5 SCAR=16.8
Pod undocumented
36 3 my $self = shift;
37 3 ▶ unless( $self->form ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->form) 3 0 3
38 3 ▶ if( $self->has_input ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_input) { } 3 0 3
39 3 $self->_result_from_input( $self->result, $self->input );;
40 }
41 else {
42 0 $self->_result_from_fields( $self->result );
43 }
44 }
45 3 $self->validate_field;
46 3 ▶ unless( $self->form ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->form) 3 0 3
47 3 foreach my $err_res (@{$self->result->error_results}) {
48 1 $self->result->_push_errors($err_res->all_errors);
49 }
50 }
51 }
52  
53 50 ▶around '_result_from_object' => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
54 50 my $orig = shift;
55 50 my $self = shift;
56 50 my ( $self_result, $item ) = @_;
57 50 ▶ $self->item($item) if $item;
Branch: 1 branch
BranchTrueFalseTotal
if $item 50 0 50
58 50 $self->$orig(@_);
59 56 };
60  
61 93 ▶after 'clear_data' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
62 93 my $self = shift;
63 93 $self->clear_item;
64 56 };
65  
66 104 ▶around '_result_from_input' => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
67 104 my $orig = shift;
68 104 my $self = shift;
69 104 my ( $self_result, $input, $exists ) = @_;
70 104 ▶ if ( !$input && !$exists ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $input || $exists) { } 7 97 104
Condition66%2/3
$input || $exists
l!l&&r!l&&!r
9707
MC/DC50%1/2
$input || $exists
$input $exists
Truth table66%2/3
A || B
A= $inputB= $exists
ABresult
1X1
011
000
71 7 return $self->_result_from_fields($self_result);
72 }
73 else {
74 97 return $self->$orig(@_);
75 }
76 56 };
77  
78 56 __PACKAGE__->meta->make_immutable;
79 56 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
80 56 1;
81  
82 __END__
« FormHandler/TraitFor/I18N.pm ↑ Summary FormHandler/Moose.pm »