| 1 | package Workflow::Persister::DBI::AutoGeneratedId; | ||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||
| 3 | 19 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 4 | 19 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 5 | 19 | ▶ | use v5.14.0; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 6 | 19 | ▶ | use parent qw( Class::Accessor ); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 7 | 19 | ▶ | use Log::Any; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 8 | 19 | ▶ | use Workflow::Exception qw( configuration_error ); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||
| 10 | 19 | $Workflow::Persister::DBI::AutoGeneratedId::VERSION = '2.12'; | |||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||
| 12 | 19 | my @FIELDS = qw( log from_handle handle_property func_property ); | |||||||||||||||||||||||||||||||||||
| 13 | 19 | __PACKAGE__->mk_accessors(@FIELDS); | |||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||
| 15 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=20.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 16 | 3 | my ( $class, $params ) = @_; | |||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||
| 18 | 3 | my $self = | |||||||||||||||||||||||||||||||||||
| 19 | bless { log => Log::Any->get_logger( category => $class ) }, $class; | ||||||||||||||||||||||||||||||||||||
| 20 | 3 | for (@FIELDS) { | |||||||||||||||||||||||||||||||||||
| 21 | 12 | ▶ | $self->$_( $params->{$_} ) if ( $params->{$_} ); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||
| 23 | 3 | ▶ | if ( my $handle_type = $self->from_handle ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | unless ( $handle_type =~ /^(database|statement)$/ ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 25 | 0 | configuration_error "Parameter 'from_handle' must be 'database' ", | |||||||||||||||||||||||||||||||||||
| 26 | "or 'statement' (Given: '$handle_type')"; | ||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||
| 28 | 2 | ▶ | unless ( $self->handle_property ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 29 | 0 | configuration_error "If you specify 'from_handle' you must ", | |||||||||||||||||||||||||||||||||||
| 30 | "specify a value for 'handle_property'"; | ||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||
| 32 | 2 | $self->log->debug( "Using '", $self->handle_property, "' from ", "'", | |||||||||||||||||||||||||||||||||||
| 33 | $self->from_handle, "' for ID generator" ); | ||||||||||||||||||||||||||||||||||||
| 34 | } elsif ( !$self->func_property ) { | ||||||||||||||||||||||||||||||||||||
| 35 | 0 | configuration_error "If you do not specify a value in 'from_handle' ", | |||||||||||||||||||||||||||||||||||
| 36 | "you must specify a value for 'func_property'"; | ||||||||||||||||||||||||||||||||||||
| 37 | } else { | ||||||||||||||||||||||||||||||||||||
| 38 | 1 | $self->log->debug( "Using database func() property '", | |||||||||||||||||||||||||||||||||||
| 39 | $self->func_property, "' for ID generator" ); | ||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||
| 41 | 3 | return $self; | |||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||
| 44 | 3 | ▶ | sub pre_fetch_id {return} | ||||||||||||||||||||||||||||||||||
|
Subroutine
pre_fetch_id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||
| 46 | 3 | ▶ | sub post_fetch_id { | ||||||||||||||||||||||||||||||||||
|
Subroutine
post_fetch_id: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 47 | 3 | my ( $self, $dbh, $sth ) = @_; | |||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||
| 49 | 3 | my $from_handle = $self->from_handle; | |||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||
| 51 | 3 | ▶ | if ( defined $from_handle and $from_handle eq 'database' ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
defined $from_handle and $from_handle eq "database"
MC/DC100%2/2
defined $from_handle and $from_handle eq "database"
defined $from_handle
$from_handle eq "database"
Truth table100%3/3
A and B
A= defined $from_handleB= $from_handle eq "database"
| |||||||||||||||||||||||||||||||||||||
| 52 | 1 | return $dbh->{ $self->handle_property }; | |||||||||||||||||||||||||||||||||||
| 53 | ▶ | } elsif ( defined $from_handle and $from_handle eq 'statement' ) { | |||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $from_handle and $from_handle eq "statement"
MC/DC50%1/2
defined $from_handle and $from_handle eq "statement"
defined $from_handle
$from_handle eq "statement"
Truth table66%2/3
A and B
A= defined $from_handleB= $from_handle eq "statement"
| |||||||||||||||||||||||||||||||||||||
| 54 | 1 | return $sth->{ $self->handle_property }; | |||||||||||||||||||||||||||||||||||
| 55 | } elsif ( my $func_property = $self->func_property ) { | ||||||||||||||||||||||||||||||||||||
| 56 | 1 | return $dbh->func($func_property); | |||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||
| 60 | 19 | 1; | |||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||
| 62 | __END__ | ||||||||||||||||||||||||||||||||||||