Shakan/Model/Teng.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 52 CC 3 SCAR 12.8
CC
3
Cov
0%
create
6.0
update
6.0
fill
2.0
CRAP 3.6
1 package HTML::Shakan::Model::Teng;
2 use strict;
3 use warnings;
4 use Mouse;
5 with 'HTML::Shakan::Role::Model';
6  
7 sub fill {
8 my ($self, $row) = @_;
9 my $columns = $row->get_columns;
10 while (my ($k, $v) = each %$columns) {
11 $self->form->fillin_params->{$k} = $v;
12 }
13 }
14  
15 sub create {
16 my ($self, $model, $name) = @_;
17 my $row = {};
18 my $params = $self->form->params();
19 for my $column (@{ $model->schema->get_table($name)->columns() }) {
20 next unless exists $params->{$column};
21 $row->{$column} = $params->{$column};
22 }
23 $model->insert($name => $row);
24 }
25  
26 sub insert { shift->create(@_) }
27  
28 sub update {
29 my ($self, $row) = @_;
30 my $dat = {};
31 my $columns = $row->get_columns;
32 my $params = $self->form->params();
33 for my $column (keys %$columns) {
34 next unless exists $params->{$column};
35 $dat->{$column} = $params->{$column};
36 }
37 $row->update($dat);
38 }
39  
40 no Mouse;
41 __PACKAGE__->meta->make_immutable;
42 __END__