| 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
| |||||||||||
| 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
| |||||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | Carp::croak("columns must be a hashref") | ||||||||||
| 25 | 100 | ▶ | unless ref $def->{columns} eq 'HASH'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | |||||||||||
| 27 | Carp::croak("column_order must be an arrayref") | ||||||||||
| 28 | 100 | ▶ | unless ref $def->{column_order} eq 'ARRAY'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | |||||||||||
| 30 | Carp::croak("primary_key must be an arrayref") | ||||||||||
| 31 | 100 | ▶ | unless ref $def->{primary_key} eq 'ARRAY'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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__ | ||||||||||