File Coverage

blib/lib/ObjectDB/DBHPool.pm
Criterion Covered Total %
statement 9 26 34.6
branch 0 2 0.0
condition 0 6 0.0
subroutine 3 5 60.0
pod 0 2 0.0
total 12 41 29.2


line stmt bran cond sub pod time code
1             package ObjectDB::DBHPool;
2              
3 5     5   40 use strict;
  5         12  
  5         147  
4 5     5   23 use warnings;
  5         13  
  5         214  
5              
6             our $VERSION = '3.27';
7              
8             require Carp;
9 5     5   2392 use ObjectDB::DBHPool::Connection;
  5         14  
  5         1127  
10              
11             sub new {
12 0     0 0   my $class = shift;
13 0           my (%params) = @_;
14              
15 0           my $self = {};
16 0           bless $self, $class;
17              
18 0           $self->{check_timeout} = $params{check_timeout};
19 0           $self->{dsn} = $params{dsn};
20 0           $self->{username} = $params{username};
21 0           $self->{password} = $params{password};
22 0           $self->{attrs} = $params{attrs};
23 0           $self->{do} = $params{do};
24              
25 0           $self->{connections} = {};
26              
27 0           return $self;
28             }
29              
30             sub dbh {
31 0     0 0   my $self = shift;
32              
33             # From DBIx::Connector
34 0           my $pid_tid = $$;
35             $pid_tid .= '_' . threads->tid
36 0 0 0       if exists $INC{'threads.pm'} && $INC{'threads.pm'};
37              
38             my $connection = $self->{connections}->{$pid_tid} ||= ObjectDB::DBHPool::Connection->new(
39             check_timeout => $self->{check_timeout},
40             dsn => $self->{dsn},
41             username => $self->{username},
42             password => $self->{password},
43             attrs => $self->{attrs},
44             do => $self->{do},
45 0   0       );
46              
47 0           return $connection->dbh;
48             }
49              
50             1;