blib/lib/Rose/HTML/Object/Repeatable.pm

filter: Statementstmt 92.1% 47 / 51 Branchbran 86.3% 19 / 22 Conditioncond 80.0% 4 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 91.6% 11 / 12 Podpod 33.3% 2 / 6 totaltotal 84.8% 84 / 99 CC 16 SCAR 14.4
CC
16
Cov
90%
empty_is_ok
7.0
prototype_spec
6.1
prototype_clone
4.0
CRAP 4.2
« blib/lib/Rose/HTML/Form/Field/DateTime/Range.pm ↑ Summary blib/lib/Rose/HTML/Form/Field/Option/Container.pm »
1 package Rose::HTML::Object::Repeatable;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Clone::PP();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use base 'Rose::HTML::Form';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 our $VERSION = '0.613';
11  
12 #
13 # Class data
14 #
15  
16 use Rose::Class::MakeMethods::Generic
17 2 ▶(
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 inheritable_scalar =>
19 [
20 'default_prototype_class',
21 ],
22 2 );
23  
24 #
25 # Object data
26 #
27  
28 use Rose::Object::MakeMethods::Generic
29 2 ▶(
Subroutine BEGIN: called CC=1 SCAR=0.0
30 2 scalar =>
31 [
32 'default_count' => { interface => 'get_set_init' },
33 'prototype',
34 ],
35 2 );
36  
37 0 ▶sub init_default_count { 0 }
Subroutine init_default_count: not called CC=1 SCAR=6.9
Pod undocumented
38  
39 7 ▶sub is_repeatable { 1 }
Subroutine is_repeatable: called CC=1 SCAR=0.0
Pod documented
40  
41 sub prototype_class
42 10 ▶{
Subroutine prototype_class: called CC=3 SCAR=11.0
Pod undocumented
43 10 my($self) = shift;
44  
45 10 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 4 6 10
46 {
47 4 return $self->{'prototype_class'} = shift;
48 }
49  
50 6 ▶ return $self->{'prototype_class'} || ref($self)->default_prototype_class;
Condition66%2/3
$self->{'prototype_class'} || ref($self)->default_prototype_class
l!l&&r!l&&!r
420
MC/DC0%0/2
$self->{'prototype_class'} || ref($self)->default_prototype_class
$self->{'prototype_class'} ref($self)->default_prototype_class
Truth table66%2/3
A || B
A= $self->{'prototype_class'}B= ref($self)->default_prototype_class
ABresult
1X1
011
000
51 }
52  
53 sub prototype_spec
54 9 ▶{
Subroutine prototype_spec: called CC=5 SCAR=18.1
Pod undocumented
55 9 my($self) = shift;
56  
57 9 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 3 6 9
58 {
59 3 ▶ if(@_ == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 3 0 3
60 {
61 3 ▶ if(ref($_[0]) eq 'ARRAY')
Branch: 2 branches
BranchTrueFalseTotal
if (ref $_[0] eq 'ARRAY') { } 0 3 3
elsif (ref $_[0] eq 'HASH') { } 3 0 3
62 {
63 0 $self->{'prototype_spec'} = shift;
64 }
65 elsif(ref($_[0]) eq 'HASH')
66 {
67 3 $self->{'prototype_spec'} = shift;
68 }
69 else
70 {
71 0 croak "Invalid prototype spec: @_";
72 }
73 }
74 else
75 {
76 0 $self->{'prototype_spec'} = [ @_ ];
77 }
78 }
79  
80 9 return $self->{'prototype_spec'};
81 }
82  
83 sub prototype_clone
84 34 ▶{
Subroutine prototype_clone: called CC=4 SCAR=13.9
Pod undocumented
85 34 my($self) = shift;
86  
87 34 ▶ if(my $obj = $self->prototype)
Branch: 1 branch
BranchTrueFalseTotal
if (my $obj = $self->prototype) { } 28 6 34
88 {
89 28 return Clone::PP::clone($obj);
90 }
91 else
92 {
93 6 ▶ my $args = $self->prototype_spec || [];
Condition100%2/2
$self->prototype_spec || []
l!l
33
MC/DC100%1/1
$self->prototype_spec || []
$self->prototype_spec
Truth table100%2/2
A
A= $self->prototype_spec
Aresult
11
00
94 6 ▶ $args = [ %$args ] if(ref $args eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
if ref $args eq "HASH" 3 3 6
95 6 return $self->prototype_class->new(@$args);
96 }
97 }
98  
99 sub empty_is_ok
100 41 ▶{
Subroutine empty_is_ok: called CC=7 SCAR=19.5
Pod documented
101 41 my($self) = shift;
102  
103 41 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 4 37 41
104 {
105 4 foreach my $form ($self->forms)
106 {
107 2 $form->empty_is_ok(@_);
108 }
109  
110 4 ▶ return $self->{'empty_is_ok'} = $_[0] ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$_[0] ? : 3 1 4
111 }
112  
113 37 my $forms = $self->forms;
114  
115 37 ▶ return $self->{'empty_is_ok'} unless(@$forms);
Branch: 1 branch
BranchTrueFalseTotal
unless @$forms 10 27 37
116  
117 27 foreach my $form (@$forms)
118 {
119 28 ▶ return 0 unless($form->empty_is_ok);
Branch: 1 branch
BranchTrueFalseTotal
unless $form->empty_is_ok 21 7 28
120 }
121  
122 6 return 1;
123 }
124  
125 2 1;
« blib/lib/Rose/HTML/Form/Field/DateTime/Range.pm ↑ Summary blib/lib/Rose/HTML/Form/Field/Option/Container.pm »