blib/lib/DBIO/ChangeLog/Table.pm

filter: Statementstmt 100% 23 / 23 Branchbran 50.0% 5 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 87.5% 35 / 40 CC 7 SCAR 16.8
CC
7
Cov
85%
validate_definition
7.9
BEGIN
1.0
BEGIN
1.0
CRAP 5.4
« blib/lib/DBIO/ChangeLog.pm ↑ Summary blib/lib/DBIO/DeploymentHandler/Dad.pm »
1 package DBIO::ChangeLog::Table;
2 # ABSTRACT: Shared utilities for changelog table source definitions
3  
4 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 12 our $VERSION = '0.900007';
8  
9 12 ▶use base 'DBIO::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12  
13 100 ▶sub validate_definition {
Subroutine validate_definition: called CC=7 SCAR=20.7
Pod documented
14 100 my ($class, $def) = @_;
15 100 require Carp;
16 100 ▶ Carp::croak("source_definition must return a hashref")
Branch: 1 branch
BranchTrueFalseTotal
unless ref $def eq "HASH" 0 100 100
17 unless ref $def eq 'HASH';
18  
19 100 for my $key (qw/ table columns column_order primary_key /) {
20 Carp::croak("source_definition missing required key: $key")
21 400 ▶ unless exists $def->{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $def->{$key} 0 400 400
22 }
23  
24 Carp::croak("columns must be a hashref")
25 100 ▶ unless ref $def->{columns} eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $def->{"columns"} eq "HASH" 0 100 100
26  
27 Carp::croak("column_order must be an arrayref")
28 100 ▶ unless ref $def->{column_order} eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $def->{"column_order"} eq "ARRAY" 0 100 100
29  
30 Carp::croak("primary_key must be an arrayref")
31 100 ▶ unless ref $def->{primary_key} eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $def->{"primary_key"} eq "ARRAY" 0 100 100
32  
33 100 return $def;
34 }
35  
36  
37 100 ▶sub build_source {
Subroutine build_source: called CC=1 SCAR=0.0
Pod documented
38 100 my ($class, $def) = @_;
39 100 $class->validate_definition($def);
40  
41 return {
42 table => $def->{table},
43 columns => $def->{columns},
44 column_order => $def->{column_order},
45 primary_key => $def->{primary_key},
46 100 };
47 }
48  
49 12 1;
50  
51 __END__
« blib/lib/DBIO/ChangeLog.pm ↑ Summary blib/lib/DBIO/DeploymentHandler/Dad.pm »