File Coverage

blib/lib/Rose/HTML/Form/Field/OnOff/Checkable.pm
Criterion Covered Total %
statement 31 32 96.8
branch 19 20 95.0
condition 1 3 33.3
subroutine 9 9 100.0
pod 3 7 42.8
total 63 71 88.7


line stmt bran cond sub pod time code
1              
2             use strict;
3 9     9   59  
  9         18  
  9         233  
4             use base 'Rose::HTML::Form::Field::OnOff';
5 9     9   36  
  9         16  
  9         3926  
6             our $VERSION = '0.606';
7              
8             __PACKAGE__->add_required_html_attrs(
9             {
10             value => 'on',
11             });
12              
13             {
14             my($self) = shift;
15              
16 1204     1204 0 1582 if(@_)
17             {
18 1204 100       2135 $self->is_cleared(0);
19              
20 555         1240 $self->{'checked'} =
21             $self->html_attr(checked => $_[0] ? 1 : (defined $_[0] ? 0 : undef));
22 555 100       2519  
    100          
23             if((my $parent = $self->parent_field) && $self->auto_invalidate_parent)
24             {
25 555 50 33     1183 $parent->invalidate_value;
26             }
27 0         0  
28             return $self->{'checked'};
29             }
30 555         1018  
31             return 0 if($self->is_cleared);
32             return defined $self->{'checked'} ? $self->{'checked'} : $self->default_value;
33 649 100       1248 }
34 556 100       3725  
35             *input_value = \&checked;
36              
37              
38              
39 259 100   259 0 416  
40             {
41 259     259 0 422 my($self) = shift;
42              
43 143     143 1 898 $self->checked(0);
44             $self->error(undef);
45             $self->is_cleared(1);
46             }
47 380     380 1 543  
48             {
49 380         810 my($self) = shift;
50 380         922  
51 380         736 $self->checked(undef);
52             $self->error(undef);
53             $self->is_cleared(0);
54             return 1;
55             }
56 42     42 1 62  
57             {
58 42         85 my($self) = shift;
59 42         128  
60 42         101 if(@_)
61 42         155 {
62             if($self->{'_hidden'} = shift(@_) ? 1 : 0)
63             {
64             $self->checked(undef);
65             }
66 387     387 0 509 }
67              
68 387 100       603 return $self->{'_hidden'};
69             }
70 32 100       100  
    100          
71             1;