File Coverage

blib/lib/Rose/HTML/Object/Repeatable.pm
Criterion Covered Total %
statement 45 49 91.8
branch 19 22 86.3
condition 4 5 80.0
subroutine 11 12 91.6
pod 2 6 33.3
total 81 94 86.1


line stmt bran cond sub pod time code
1              
2             use strict;
3 2     2   14  
  2         4  
  2         50  
4             use Carp;
5 2     2   8 use Clone::PP();
  2         5  
  2         116  
6 2     2   10  
  2         4  
  2         28  
7             use base 'Rose::HTML::Form';
8 2     2   7  
  2         4  
  2         264  
9             our $VERSION = '0.613';
10              
11             #
12             # Class data
13             #
14              
15             use Rose::Class::MakeMethods::Generic
16             (
17             inheritable_scalar =>
18 2         26 [
19             'default_prototype_class',
20             ],
21             );
22 2     2   13  
  2         4  
23             #
24             # Object data
25             #
26              
27             use Rose::Object::MakeMethods::Generic
28             (
29             scalar =>
30 2         20 [
31             'default_count' => { interface => 'get_set_init' },
32             'prototype',
33             ],
34             );
35 2     2   339  
  2         5  
36              
37 0     0 0 0  
38             {
39 7     7 1 20 my($self) = shift;
40              
41             if(@_)
42             {
43 10     10 0 16 return $self->{'prototype_class'} = shift;
44             }
45 10 100       20  
46             return $self->{'prototype_class'} || ref($self)->default_prototype_class;
47 4         15 }
48              
49             {
50 6   66     35 my($self) = shift;
51              
52             if(@_)
53             {
54             if(@_ == 1)
55 9     9 0 15 {
56             if(ref($_[0]) eq 'ARRAY')
57 9 100       24 {
58             $self->{'prototype_spec'} = shift;
59 3 50       7 }
60             elsif(ref($_[0]) eq 'HASH')
61 3 50       10 {
    50          
62             $self->{'prototype_spec'} = shift;
63 0         0 }
64             else
65             {
66             croak "Invalid prototype spec: @_";
67 3         5 }
68             }
69             else
70             {
71 0         0 $self->{'prototype_spec'} = [ @_ ];
72             }
73             }
74              
75             return $self->{'prototype_spec'};
76 0         0 }
77              
78             {
79             my($self) = shift;
80 9         27  
81             if(my $obj = $self->prototype)
82             {
83             return Clone::PP::clone($obj);
84             }
85 34     34 0 62 else
86             {
87 34 100       118 my $args = $self->prototype_spec || [];
88             $args = [ %$args ] if(ref $args eq 'HASH');
89 28         107 return $self->prototype_class->new(@$args);
90             }
91             }
92              
93 6   100     21 {
94 6 100       23 my($self) = shift;
95 6         19  
96             if(@_)
97             {
98             foreach my $form ($self->forms)
99             {
100             $form->empty_is_ok(@_);
101 41     41 1 99 }
102              
103 41 100       87 return $self->{'empty_is_ok'} = $_[0] ? 1 : 0;
104             }
105 4         11  
106             my $forms = $self->forms;
107 2         8  
108             return $self->{'empty_is_ok'} unless(@$forms);
109              
110 4 100       20 foreach my $form (@$forms)
111             {
112             return 0 unless($form->empty_is_ok);
113 37         82 }
114              
115 37 100       138 return 1;
116             }
117 27         62  
118             1;