DBI/Column.pm

filter: Statementstmt 100% 28 / 28 Branchbran 75.0% 3 / 4 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 10 / 10 Podpod 20.0% 1 / 5 totaltotal 90.0% 45 / 50 CC 4 SCAR 4.8
CC
4
Cov
97%
new
3.0
groups
2.0
BEGIN
1.0
CRAP 1.6
« DBI/Relationship.pm ↑ Summary DBI/Cascade/None.pm »
1 package Class::DBI::Column;
2  
3 =head1 NAME
4  
5 Class::DBI::Column - A column in a table
6  
7 =head1 SYNOPSIS
8  
9 my $column = Class::DBI::Column->new($name);
10  
11 my $name = $column->name;
12  
13 my @groups = $column->groups;
14 my $pri_col = $colg->primary;
15  
16 if ($column->in_database) { ... }
17  
18 =head1 DESCRIPTION
19  
20 Each Class::DBI class maintains a list of its columns as class data.
21 This provides an interface to those columns. You probably shouldn't be
22 dealing with this directly.
23  
24 =head1 METHODS
25  
26 =cut
27  
28 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 4 ▶use base 'Class::Accessor::Fast';
Subroutine BEGIN: called CC=1 SCAR=0.0
30 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 4 __PACKAGE__->mk_accessors(
33 qw/name accessor mutator placeholder is_constrained/
34 );
35  
36 use overload
37 130 ▶ '""' => sub { shift->name_lc },
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
38 4 fallback => 1;
39  
40 =head2 new
41  
42 my $column = Class::DBI::Column->new($column)
43  
44 A new object for this column.
45  
46 =cut
47  
48 32 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod documented
49 32 my $class = shift;
50 32 ▶ my $name = shift or croak "Column needs a name";
Branch: 1 branch
BranchTrueFalseTotal
my $name = shift() or croak("Column needs a name") 32 0 32
51 32 ▶ my $opt = shift || {};
Condition100%2/2
shift() || {}
l!l
131
MC/DC100%1/1
shift() || {}
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
52 32 return $class->SUPER::new(
53 {
54 name => $name,
55 accessor => $name,
56 mutator => $name,
57 _groups => {},
58 placeholder => '?',
59 %$opt,
60 }
61 );
62 }
63  
64 205 ▶sub name_lc { lc shift->name }
Subroutine name_lc: called CC=1 SCAR=0.0
Pod undocumented
65  
66 36 ▶sub add_group {
Subroutine add_group: called CC=1 SCAR=0.0
Pod undocumented
67 36 my ($self, $group) = @_;
68 36 $self->{_groups}->{$group} = 1;
69 }
70  
71 34 ▶sub groups {
Subroutine groups: called CC=2 SCAR=6.9
Pod undocumented
72 34 my $self = shift;
73 34 my %groups = %{ $self->{_groups} };
74 34 ▶ delete $groups{All} if keys %groups > 1;
Branch: 1 branch
BranchTrueFalseTotal
if keys %groups > 1 10 24 34
75 34 return keys %groups;
76 }
77  
78 32 ▶sub in_database {
Subroutine in_database: called CC=1 SCAR=0.0
Pod undocumented
79 32 return !scalar grep $_ eq "TEMP", shift->groups;
80 }
81  
82 4 1;
« DBI/Relationship.pm ↑ Summary DBI/Cascade/None.pm »