File Coverage

blib/lib/Salus/Row.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package Salus::Row;
2              
3 3     3   22 use Rope;
  3         6  
  3         28  
4 3     3   1070 use Rope::Autoload;
  3         5  
  3         25  
5 3     3   198 use Types::Standard qw/ArrayRef/;
  3         5  
  3         20  
6 3     3   5653 use Salus::Row::Column;
  3         8  
  3         1165  
7              
8             property columns => (
9             initable => 1,
10             writeable => 0,
11             configurable => 1,
12             required => 1,
13             enumerable => 1,
14             type => ArrayRef,
15             value => []
16             );
17              
18             function as_array => sub {
19             my ($self) = @_;
20             return [map {
21             $_->value
22             } @{$self->columns}];
23             };
24              
25             function get_col => sub {
26             my ($self, $col) = @_;
27             if ($col !~ m/^\d+$/) {
28             for (@{$self->columns}) {
29             if ($_->header->name =~ m/^($col)$/) {
30             $col = $_->header->index;
31             }
32             }
33             }
34             return $self->columns->[$col];
35             };
36              
37             function set_col => sub {
38             my ($self, $col, $value) = @_;
39             $self->get_col($col)->value = $value;
40             };
41              
42             function delete_col => sub {
43             my ($self, $col) = @_;
44             $self->get_col($col)->value = '';
45             };
46              
47             1;