DBIx/Class/ResultSourceProxy/Table.pm

filter: Statementstmt 72.0% 31 / 43 Branchbran 50.0% 8 / 16 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 87.5% 7 / 8 Podpod 100% 1 / 1 totaltotal 61.5% 48 / 78 CC 11 SCAR 24.4
CC
11
Cov
62%
_init_result_source_instance
30.0
table
7.3
BEGIN
1.0
CRAP 11.5
« DBIx/Class/Storage/DBI/Sybase.pm ↑ Summary DBIx/Class/Storage/DBI/DB2.pm »
1 package DBIx::Class::ResultSourceProxy::Table;
2  
3 308 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 308 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 308 ▶use base qw/DBIx::Class::ResultSourceProxy/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 308 ▶use DBIx::Class::ResultSource::Table;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 308 ▶use Scalar::Util 'blessed';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 308 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 308 __PACKAGE__->mk_classdata(table_class => 'DBIx::Class::ResultSource::Table');
13  
14 308 __PACKAGE__->mk_classdata('table_alias'); # FIXME: Doesn't actually do
15 # anything yet!
16  
17 sub _init_result_source_instance {
18 0 ▶ my $class = shift;
Subroutine _init_result_source_instance: not called CC=5 SCAR=34.0
19  
20 0 ▶ $class->mk_classdata('result_source_instance')
Branch: 1 branch
BranchTrueFalseTotal
unless $class->can("result_source_instance") 0 0 0
21 unless $class->can('result_source_instance');
22  
23 0 my $table = $class->result_source_instance;
24 0 ▶ my $class_has_table_instance = ($table and $table->result_class eq $class);
Condition0%0/3
$table && $table->result_class eq $class
!ll&&!rl&&r
000
MC/DC0%0/2
$table && $table->result_class eq $class
$table $table->result_class eq $class
Truth table0%0/3
A && B
A= $tableB= $table->result_class eq $class
ABresult
0X0
100
111
25 0 ▶ return $table if $class_has_table_instance;
Branch: 1 branch
BranchTrueFalseTotal
if $class_has_table_instance 0 0 0
26  
27 0 my $table_class = $class->table_class;
28 0 $class->ensure_class_loaded($table_class);
29  
30 0 ▶ if( $table ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($table) { } 0 0 0
31 0 $table = $table_class->new({
32 %$table,
33 result_class => $class,
34 source_name => undef,
35 schema => undef
36 });
37 }
38 else {
39 0 $table = $table_class->new({
40 name => undef,
41 result_class => $class,
42 source_name => undef,
43 });
44 }
45  
46 0 $class->result_source_instance($table);
47  
48 0 return $table;
49 }
50  
51 =head1 NAME
52  
53 DBIx::Class::ResultSourceProxy::Table - provides a classdata table
54 object and method proxies
55  
56 =head1 SYNOPSIS
57  
58 __PACKAGE__->table('cd');
59 __PACKAGE__->add_columns(qw/cdid artist title year/);
60 __PACKAGE__->set_primary_key('cdid');
61  
62 =head1 METHODS
63  
64 =head2 add_columns
65  
66 __PACKAGE__->add_columns(qw/cdid artist title year/);
67  
68 Adds columns to the current class and creates accessors for them.
69  
70 =cut
71  
72 =head2 table
73  
74 __PACKAGE__->table('tbl_name');
75  
76 Gets or sets the table name.
77  
78 =cut
79  
80 sub table {
81 15270 ▶ my ($class, $table) = @_;
Subroutine table: called CC=7 SCAR=19.8
Pod documented
82 15270 ▶ return $class->result_source_instance->name unless $table;
Branch: 1 branch
BranchTrueFalseTotal
unless $table 618 14652 15270
83  
84 14652 ▶ unless (blessed $table && $table->isa($class->table_class)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($table) and $table->isa($class->table_class)) 14652 0 14652
Condition33%1/3
builtin::blessed($table) and $table->isa($class->table_class)
!ll&&!rl&&r
1465200
MC/DC0%0/2
builtin::blessed($table) and $table->isa($class->table_class)
builtin::blessed($table) $table->isa($class->table_class)
Truth table33%1/3
A and B
A= builtin::blessed($table)B= $table->isa($class->table_class)
ABresult
0X0
100
111
85  
86 14652 my $table_class = $class->table_class;
87 14652 $class->ensure_class_loaded($table_class);
88  
89 $table = $table_class->new({
90 $class->can('result_source_instance')
91 14652 ▶ ? %{$class->result_source_instance||{}}
Branch: 2 branches
BranchTrueFalseTotal
$class->can('result_source_instance') ? : 14188 464 14652
$class->result_source_instance or {} 0 14188 14188
92 : ()
93 ,
94 name => $table,
95 result_class => $class,
96 });
97 }
98  
99 14652 ▶ $class->mk_classdata('result_source_instance')
Branch: 1 branch
BranchTrueFalseTotal
unless $class->can("result_source_instance") 464 14188 14652
100 unless $class->can('result_source_instance');
101  
102 14652 $class->result_source_instance($table);
103  
104 14652 return $class->result_source_instance->name;
105 }
106  
107 =head2 table_class
108  
109 __PACKAGE__->table_class('DBIx::Class::ResultSource::Table');
110  
111 Gets or sets the table class used for construction and validation.
112  
113 =cut
114  
115 =head2 has_column
116  
117 if ($obj->has_column($col)) { ... }
118  
119 Returns 1 if the class has a column of this name, 0 otherwise.
120  
121 =cut
122  
123 =head2 column_info
124  
125 my $info = $obj->column_info($col);
126  
127 Returns the column metadata hashref for a column. For a description of
128 the various types of column data in this hashref, see
129 L<DBIx::Class::ResultSource/add_column>
130  
131 =cut
132  
133 =head2 columns
134  
135 my @column_names = $obj->columns;
136  
137 =cut
138  
139 308 1;
140  
141 =head1 AUTHOR AND CONTRIBUTORS
142  
143 See L<AUTHOR|DBIx::Class/AUTHOR> and L<CONTRIBUTORS|DBIx::Class/CONTRIBUTORS> in DBIx::Class
144  
145 =head1 LICENSE
146  
147 You may distribute this code under the same terms as Perl itself.
148  
149 =cut
150  
« DBIx/Class/Storage/DBI/Sybase.pm ↑ Summary DBIx/Class/Storage/DBI/DB2.pm »