| 1 | package Prancer::Plugin::Database::Driver::Mock; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 2 | ▶ | use warnings FATAL => 'all'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | 2 | ▶ | use version; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 2 | our $VERSION = '1.04'; | |||||||||||||
| 8 | |||||||||||||||
| 9 | 2 | ▶ | use Prancer::Plugin::Database::Driver; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | 2 | ▶ | use parent qw(Prancer::Plugin::Database::Driver); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | |||||||||||||||
| 12 | 2 | ▶ | use Try::Tiny; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 13 | 2 | ▶ | use Carp; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 14 | |||||||||||||||
| 15 | # even though this *should* work automatically, it was not | ||||||||||||||
| 16 | 2 | our @CARP_NOT = qw(Prancer Try::Tiny); | |||||||||||||
| 17 | |||||||||||||||
| 18 | 7 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: called CC=3 SCAR=12.2
Pod
undocumented
| |||||||||||||||
| 19 | 7 | my $class = shift; | |||||||||||||
| 20 | 7 | my $self = bless($class->SUPER::new(@_), $class); | |||||||||||||
| 21 | |||||||||||||||
| 22 | 7 | ▶ | try { | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 23 | 7 | require DBD::Mock; | |||||||||||||
| 24 | 0 | ▶ | } catch { | ||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||
| 25 | 0 | ▶ | my $error = (defined($_) ? $_ : "unknown"); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 26 | 0 | croak "could not initialize database connection '${\$self->{'_connection'}}': could not load DBD::Mock: ${error}"; | |||||||||||||
| 27 | 7 | }; | |||||||||||||
| 28 | |||||||||||||||
| 29 | 7 | my $database = $self->{'_database'}; | |||||||||||||
| 30 | |||||||||||||||
| 31 | # if autocommit isn't configured then enable it by default | ||||||||||||||
| 32 | 7 | ▶ | my $autocommit = (defined($self->{'_autocommit'}) ? ($self->{'_autocommit'} =~ /^(1|true|yes)$/ix ? 1 : 0) : 1); | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 33 | |||||||||||||||
| 34 | 7 | my $dsn = "dbi:Mock:"; | |||||||||||||
| 35 | |||||||||||||||
| 36 | 7 | my $params = { | |||||||||||||
| 37 | 'AutoCommit' => $autocommit, | ||||||||||||||
| 38 | 'RaiseError' => 1, | ||||||||||||||
| 39 | 'PrintError' => 0, | ||||||||||||||
| 40 | }; | ||||||||||||||
| 41 | |||||||||||||||
| 42 | # merge in any additional dsn_params | ||||||||||||||
| 43 | 7 | $params = $self->_merge($params, $self->{'_dsn_extra'}); | |||||||||||||
| 44 | |||||||||||||||
| 45 | 7 | $self->{'_dsn'} = [ $dsn, undef, undef, $params ]; | |||||||||||||
| 46 | 7 | return $self; | |||||||||||||
| 47 | } | ||||||||||||||
| 48 | |||||||||||||||
| 49 | 2 | 1; | |||||||||||||