Model/Row.pm

filter: Statementstmt 44.1% 15 / 34 Branchbran 0.0% 0 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 36.3% 4 / 11 Podpod 25.0% 2 / 8 totaltotal 37.9% 22 / 58 CC 4 SCAR 10.8
CC
4
Cov
42%
get_columns
6.0
get_original_column
6.0
new
2.0
CRAP 2.9
« Model/Driver/DBI/MasterSlave.pm ↑ Summary Model/Schema/Inflate.pm »
1 package Data::Model::Row;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 $Carp::Internal{(__PACKAGE__)}++;
7  
8 4 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod undocumented
9 4 my($class, $model, $columns) = @_;
10 4 ▶ $columns ||= {};
Condition50%1/2
$columns ||= {}
l!l
40
MC/DC0%0/1
$columns ||= {}
$columns
Truth table50%1/2
A
A= $columns
Aresult
11
00
11 bless {
12 model => $model,
13 4 column_values => { %{ $columns } },
14 alias_values => +{},
15 changed_cols => +{},
16 original_cols => +{},
17 }, $class;
18 }
19  
20 0 ▶sub update {
Subroutine update: not called CC=1 SCAR=6.9
Pod documented
21 0 my $self = shift;
22 0 $self->{model}->update($self, @_);
23 }
24  
25 0 ▶sub delete {
Subroutine delete: not called CC=1 SCAR=6.9
Pod documented
26 0 my $self = shift;
27 0 $self->{model}->delete($self, @_);
28 }
29  
30 0 ▶sub get_column {
Subroutine get_column: not called CC=1 SCAR=6.9
Pod undocumented
31 0 my($self, $name) = @_;
32 0 $self->{column_values}->{$name};
33 }
34 0 ▶sub get_columns {
Subroutine get_columns: not called CC=2 SCAR=17.9
Pod undocumented
35 0 my $self = shift;
36 0 my $schema = $self->{model}->_get_schema_by_row($self);
37 0 my $columns = +{};
38 0 for my $name (keys %{ $schema->{column} }) {
39 0 $columns->{$name} = $self->{column_values}->{$name};
40 }
41 0 $columns;
42 }
43  
44 0 ▶sub get_original_column {
Subroutine get_original_column: not called CC=2 SCAR=17.9
Pod undocumented
45 0 my($self, $name) = @_;
46 0 ▶ $self->{original_cols}->{$name} || $self->{column_values}->{$name};
Branch: 1 branch
BranchTrueFalseTotal
$self->{"original_cols"}{$name} or $self->{"column_values"}{$name} 0 0 0
47 }
48  
49 0 ▶sub get_changed_columns {
Subroutine get_changed_columns: not called CC=1 SCAR=6.9
Pod undocumented
50 0 my $self = shift;
51 0 +{ %{ $self->{changed_cols} } };
52 }
53  
54 0 ▶sub get_model { $_[0]->{model} }
Subroutine get_model: not called CC=1 SCAR=6.9
Pod undocumented
55  
56 1 1;
57  
58 =head1 NAME
59  
60 Data::Model::Row - Data::Model's Row class
61  
62 =head1 METHODS
63  
64 =head2 update
65  
66 update is executed for instance record.
67  
68 It works by schema in which primary key exists.
69  
70 =head2 delete
71  
72 delete is executed for instance record.
73  
74 It works by schema in which primary key exists.
75  
76 =head1 SEE ALSO
77  
78 L<Data::Model>
79  
80 =head1 AUTHOR
81  
82 Kazuhiro Osawa E<lt>yappo <at> shibuya <döt> plE<gt>
83  
84 =head1 LICENSE
85  
86 This library is free software; you can redistribute it and/or modify
87 it under the same terms as Perl itself.
88  
89 =cut
90  
« Model/Driver/DBI/MasterSlave.pm ↑ Summary Model/Schema/Inflate.pm »