Object/Metadata/Relationship/OneToMany.pm

filter: Statementstmt 80.3% 41 / 51 Branchbran 35.0% 7 / 20 Conditioncond 38.1% 8 / 21 MC/DCmcdc 16.6% 2 / 12 Subroutinesub 83.3% 10 / 12 Podpod 50.0% 3 / 6 totaltotal 58.2% 71 / 122 CC 18 SCAR 31.1
CC
18
Cov
61%
is_ready_to_make_methods
49.4
build_method_name_for_type
16.1
is_singular
2.0
CRAP 22.5
« Object/Metadata/Column/Date.pm ↑ Summary Object/Metadata/ColumnList.pm »
1 package Rose::DB::Object::Metadata::Relationship::OneToMany;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Carp();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Rose::DB::Object::Metadata::Relationship;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 our @ISA = qw(Rose::DB::Object::Metadata::Relationship);
9  
10 1 ▶use Rose::Object::MakeMethods::Generic;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Rose::DB::Object::MakeMethods::Generic;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 our $Debug = 0;
14  
15 1 our $VERSION = '0.781';
16  
17 1 __PACKAGE__->default_auto_method_types(qw(find get_set_on_save add_on_save));
18  
19 1 __PACKAGE__->add_common_method_maker_argument_names
20 (
21 qw(class share_db key_columns manager_class manager_method
22 manager_count_method manager_iterator_method manager_find_method
23 manager_args query_args join_args)
24 );
25  
26 use Rose::Object::MakeMethods::Generic
27 1 ▶(
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 boolean =>
29 [
30 'share_db' => { default => 1 },
31 ],
32  
33 hash =>
34 [
35 key_column => { hash_key => 'key_columns' },
36 key_columns => { interface => 'get_set_all' },
37 ],
38 1 );
39  
40 1 Rose::Object::MakeMethods::Generic->make_methods
41 (
42 { preserve_existing => 1 },
43 scalar =>
44 [
45 __PACKAGE__->common_method_maker_argument_names
46 ],
47 );
48  
49 1 __PACKAGE__->method_maker_info
50 (
51 count =>
52 {
53 class => 'Rose::DB::Object::MakeMethods::Generic',
54 type => 'objects_by_key',
55 interface => 'count',
56 },
57  
58 find =>
59 {
60 class => 'Rose::DB::Object::MakeMethods::Generic',
61 type => 'objects_by_key',
62 interface => 'find',
63 },
64  
65 iterator =>
66 {
67 class => 'Rose::DB::Object::MakeMethods::Generic',
68 type => 'objects_by_key',
69 interface => 'iterator',
70 },
71  
72 get_set =>
73 {
74 class => 'Rose::DB::Object::MakeMethods::Generic',
75 type => 'objects_by_key',
76 interface => 'get_set',
77 },
78  
79 get_set_now =>
80 {
81 class => 'Rose::DB::Object::MakeMethods::Generic',
82 type => 'objects_by_key',
83 interface => 'get_set_now',
84 },
85  
86 get_set_on_save =>
87 {
88 class => 'Rose::DB::Object::MakeMethods::Generic',
89 type => 'objects_by_key',
90 interface => 'get_set_on_save',
91 },
92  
93 add_now =>
94 {
95 class => 'Rose::DB::Object::MakeMethods::Generic',
96 type => 'objects_by_key',
97 interface => 'add_now',
98 },
99  
100 add_on_save =>
101 {
102 class => 'Rose::DB::Object::MakeMethods::Generic',
103 type => 'objects_by_key',
104 interface => 'add_on_save',
105 },
106 );
107  
108 8 ▶sub type { 'one to many' }
Subroutine type: called CC=1 SCAR=0.0
Pod documented
109  
110 0 ▶sub is_singular { 0 }
Subroutine is_singular: not called CC=1 SCAR=6.9
Pod documented
111  
112 0 ▶sub foreign_class { shift->class(@_) }
Subroutine foreign_class: not called CC=1 SCAR=6.9
Pod undocumented
113  
114 1 *map_column = \&key_column;
115 1 *column_map = \&key_columns;
116  
117 sub id
118 12 ▶{
Subroutine id: called CC=1 SCAR=0.0
Pod undocumented
119 12 my($self) = shift;
120  
121 12 my $column_map = $self->column_map;
122  
123 return $self->parent->class . ' ' . $self->class . ' ' .
124 12 join("\0", map { join("\1", lc $_, lc $column_map->{$_}) } sort keys %$column_map);
125 #join("\0", map { $_ . '=' . ($self->$_() || 0) } qw(required));
126 }
127  
128 sub build_method_name_for_type
129 12 ▶{
Subroutine build_method_name_for_type: called CC=9 SCAR=27.8
Pod documented
130 12 my($self, $type) = @_;
131  
132 12 ▶ if($type eq 'get_set' || $type eq 'get_set_now' || $type eq 'get_set_on_save')
Branch: 5 branches
BranchTrueFalseTotal
if ($type eq 'get_set' or $type eq 'get_set_now' or $type eq 'get_set_on_save') { } 4 8 12
elsif ($type eq 'add_now' or $type eq 'add_on_save') { } 4 4 8
elsif ($type eq 'find') { } 4 0 4
elsif ($type eq 'iterator') { } 0 0 0
elsif ($type eq 'count') { } 0 0 0
Condition50%3/6
$type eq "get_set" or $type eq "get_set_now" or $type eq "get_set_on_save"
l!l&&r!l&&!r
048
$type eq "get_set" or $type eq "get_set_now"
l!l&&r!l&&!r
0012
MC/DC33%1/3
$type eq "get_set" or $type eq "get_set_now" or $type eq "get_set_on_save"
$type eq "get_set" $type eq "get_set_now" $type eq "get_set_on_save"
Truth table50%2/4
A or B or C
A= $type eq "get_set"B= $type eq "get_set_now"C= $type eq "get_set_on_save"
ABCresult
1XX1
01X1
0011
0000
133 {
134 4 return $self->name;
135 }
136 ▶ elsif($type eq 'add_now' || $type eq 'add_on_save')
Condition66%2/3
$type eq "add_now" or $type eq "add_on_save"
l!l&&r!l&&!r
044
MC/DC50%1/2
$type eq "add_now" or $type eq "add_on_save"
$type eq "add_now" $type eq "add_on_save"
Truth table66%2/3
A or B
A= $type eq "add_now"B= $type eq "add_on_save"
ABresult
1X1
011
000
137 {
138 4 return 'add_' . $self->name;
139 }
140 elsif($type eq 'find')
141 {
142 4 return 'find_' . $self->name;
143 }
144 elsif($type eq 'iterator')
145 {
146 0 return $self->name . '_iterator';
147 }
148 elsif($type eq 'count')
149 {
150 0 return $self->name . '_count';
151 }
152  
153 0 return undef;
154 }
155  
156 sub is_ready_to_make_methods
157 4 ▶{
Subroutine is_ready_to_make_methods: called CC=10 SCAR=39.0
Pod undocumented
158 4 my($self) = shift;
159  
160 4 ▶ if($Debug || $Rose::DB::Object::Metadata::Debug)
Branch: 1 branch
BranchTrueFalseTotal
if ($Rose::DB::Object::Metadata::Relationship::OneToMany::Debug or $Rose::DB::Object::Metadata::Debug) 0 4 4
Condition33%1/3
$Rose::DB::Object::Metadata::Relationship::OneToMany::Debug or $Rose::DB::Object::Metadata::Debug
l!l&&r!l&&!r
004
MC/DC0%0/2
$Rose::DB::Object::Metadata::Relationship::OneToMany::Debug or $Rose::DB::Object::Metadata::Debug
$Rose::DB::Object::Metadata::Relationship::OneToMany::Debug $Rose::DB::Object::Metadata::Debug
Truth table33%1/3
A or B
A= $Rose::DB::Object::Metadata::Relationship::OneToMany::DebugB= $Rose::DB::Object::Metadata::Debug
ABresult
1X1
011
000
161 {
162 0 my $error;
163  
164 0 ▶ if(!$self->class)
Branch: 2 branches
BranchTrueFalseTotal
if (not $self->class) { } 0 0 0
elsif (not $self->key_columns || $self->query_args) { } 0 0 0
165 {
166 0 $error = "does not belong to a class";
167 }
168 ▶ elsif(!$self->key_columns && !$self->query_args)
Condition0%0/3
$self->key_columns || $self->query_args
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->key_columns || $self->query_args
$self->key_columns $self->query_args
Truth table0%0/3
A || B
A= $self->key_columnsB= $self->query_args
ABresult
1X1
011
000
169 {
170 0 $error = "has no key columns or query args";
171 }
172  
173 0 ▶ warn $self->parent->class, ': one-to-many relationship ', $self->name, " NOT READY - $error"
Branch: 1 branch
BranchTrueFalseTotal
if $error 0 0 0
174 if($error);
175 }
176  
177 4 ▶ return $self->class && ($self->key_columns || $self->query_args) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->class && ($self->key_columns || $self->query_args) ? : 4 0 4
Condition33%2/6
$self->class and $self->key_columns || $self->query_args
!ll&&!rl&&r
004
$self->key_columns or $self->query_args
l!l&&r!l&&!r
400
MC/DC0%0/3
$self->class and $self->key_columns || $self->query_args
$self->class $self->key_columns $self->query_args
Truth table25%1/4
A and B or C
A= $self->classB= $self->key_columnsC= $self->query_args
ABCresult
0XX0
1000
11X1
1011
178 }
179  
180 1 1;
181  
182 __END__
« Object/Metadata/Column/Date.pm ↑ Summary Object/Metadata/ColumnList.pm »