File Coverage

blib/lib/ODS/Table/Column/Base.pm
Criterion Covered Total %
statement 29 29 100.0
branch 8 8 100.0
condition 17 18 94.4
subroutine 7 7 100.0
pod 0 5 0.0
total 61 67 91.0


line stmt bran cond sub pod time code
1             package ODS::Table::Column::Base;
2              
3 70     70   27915 use YAOO;
  70         136  
  70         294  
4              
5 70     70   19801 use ODS::Utils qw/clone error/;
  70         83  
  70         362  
6              
7             auto_build;
8              
9             has name => rw, isa(string);
10              
11             has type => rw, isa(string);
12              
13             has value => rw, isa(any);
14              
15             has mandatory => rw, isa(boolean);
16              
17             has no_render => rw, isa(boolean);
18              
19             has sortable => rw, isa(any);
20              
21             has filterable => rw, isa(any);
22              
23             has field => rw, isa(hash);
24              
25             has inflated => rw, isa(boolean);
26              
27             sub build_column {
28 39378     39378 0 475941 my ($self, $data, $already_inflated, $serialize) = @_;
29              
30 39378         86358 $self = clone($self);
31              
32 39378 100 66     182626 $self->serialize_class($serialize) if $serialize && $self->can('serialize_class');
33              
34 39378         95115 $self->inflated($already_inflated);
35              
36 39378         1040281 $self->value($data);
37              
38 39378         1213425 $self->inflate($data);
39              
40 39378         782512 return $self;
41             }
42              
43             sub store_column {
44 25872     25872 0 112845 my ($self) = @_;
45              
46 25872         33478 return $self->validate()->deflate();
47             }
48              
49             sub validate {
50 51656     51656 0 155577 my ($self) = @_;
51              
52             # has_validation_class
53 51656 100 100     79379 return $self unless defined $self->value and $self->can('validation');
54              
55 44686         445087 $self->value(
56             $self->validation($self->value)
57             );
58              
59 44686         1012395 return $self;
60             }
61              
62             sub inflate {
63 39378     39378 0 57190 my ($self) = @_;
64              
65             # has_validation_class
66 39378 100 100     62337 return $self unless defined $self->value and not $self->inflated and $self->can('inflation');
      100        
67              
68 2729         77672 $self->value(
69             $self->inflation($self->value)
70             );
71              
72 2729         57179 $self->inflated(1);
73              
74 2729         127319 return $self;
75             }
76              
77             sub deflate {
78 25872     25872 0 59269 my ($self) = @_;
79              
80             # has_validation_class
81 25872 100 100     35796 return $self unless defined $self->value and $self->inflated and $self->can('deflation');
      100        
82              
83 5153         90651 $self->value(
84             $self->deflation($self->value)
85             );
86              
87 5153         112817 $self->inflated(0);
88              
89 5153         42239 return $self;
90             }
91              
92             1;
93              
94             __END__