SQLEngine/Schema/ColumnSet.pm

filter: Statementstmt 66.6% 16 / 24 Branchbran 25.0% 1 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod 80.0% 4 / 5 totaltotal 65.0% 26 / 40 CC 4 SCAR 15.3
CC
4
Cov
61%
column_named
12.0
new
2.0
columns
2.0
CRAP 4.6
« SQLEngine/Driver/Mysql.pm ↑ Summary SQLEngine/Record/Base.pm »
1 =head1 NAME
2  
3 DBIx::SQLEngine::Schema::ColumnSet - Array of Schema::Column objects
4  
5  
6 =head1 SYNOPSIS
7  
8 my $colset = DBIx::SQLEngine::Schema::ColumnSet->new( $column1, $column2 );
9
10 print $colset->count;
11
12 foreach my $column ( $colset->columns ) {
13 print $column->name;
14 }
15
16 $column = $colset->column_named( $name );
17  
18  
19 =head1 DESCRIPTION
20  
21 DBIx::SQLEngine::Schema::ColumnSet objects contain an array of DBIx::SQLEngine::Schema::Column objects
22  
23 =cut
24  
25 package DBIx::SQLEngine::Schema::ColumnSet;
26 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 6 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 ########################################################################
30  
31 =head1 REFERENCE
32  
33 =head2 Creation
34  
35 =over 4
36  
37 =item new()
38  
39 DBIx::SQLEngine::Schema::ColumnSet->new( @columns ) : $colset
40  
41 Basic array constructor.
42  
43 =back
44  
45 =cut
46  
47 5 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod documented
48 5 my $package = shift;
49 my @cols = map {
50 5 ▶ ( ref($_) eq 'HASH' ) ? DBIx::SQLEngine::Schema::Column->new_from_hash(%$_)
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'HASH' ? : 0 10 10
51 : $_
52 } @_;
53 5 bless \@cols, $package;
54 }
55  
56 ########################################################################
57  
58 =head2 Access to Columns
59  
60 =over 4
61  
62 =item columns()
63  
64 $colset->columns () : @columns
65  
66 Returns a list of column objects.
67  
68 =back
69  
70 =cut
71  
72 0 ▶sub columns {
Subroutine columns: not called CC=1 SCAR=6.9
Pod documented
73 0 my $colset = shift;
74 0 @$colset
75 }
76  
77 14 ▶sub call_method_on_columns {
Subroutine call_method_on_columns: called CC=1 SCAR=0.0
Pod undocumented
78 14 my $columns = shift;
79 14 my $method = shift;
80 14 return map { $_->$method( @_ ) } @$columns;
81 }
82  
83 ########################################################################
84  
85 =head2 Column Names
86  
87 =over 4
88  
89 =item column_names()
90  
91 $colset->column_names () : @column_names
92  
93 Returns the result of calling name() on each column.
94  
95 =item column_named()
96  
97 $colset->column_named ( $name ) : $column
98  
99 Finds the column with that name, or dies trying.
100  
101 =back
102  
103 =cut
104  
105 # @colnames = $colset->column_names;
106 14 ▶sub column_names {
Subroutine column_names: called CC=1 SCAR=0.0
Pod documented
107 14 (shift)->call_method_on_columns( 'name' )
108 }
109  
110 # $column = $colset->column_named( $column_name );
111 # $column = $colset->column_named( $column_name );
112 0 ▶sub column_named {
Subroutine column_named: not called CC=3 SCAR=24.8
Pod documented
113 0 my $colset = shift;
114 0 my $column_name = shift;
115 0 foreach ( @$colset ) {
116 0 ▶ return $_ if ( $_->name eq $column_name );
Branch: 1 branch
BranchTrueFalseTotal
if $_->name eq $column_name 0 0 0
117 }
118 croak(
119 "No column named $column_name in $colset->{name} table\n" .
120 0 " (Perhaps you meant one of these: " . join(', ', map { $_->name() . " (". $_->type() .")" } @$colset) . "?)"
121 );
122 }
123  
124 ########################################################################
125  
126 =head1 SEE ALSO
127  
128 See L<DBIx::SQLEngine> for the overall interface and developer documentation.
129  
130 See L<DBIx::SQLEngine::Docs::ReadMe> for general information about
131 this distribution, including installation and license information.
132  
133 =cut
134  
135 ########################################################################
136  
137 6 1;
« SQLEngine/Driver/Mysql.pm ↑ Summary SQLEngine/Record/Base.pm »