File Coverage

blib/lib/Database/Async/Engine.pm
Criterion Covered Total %
statement 19 27 70.3
branch 1 6 16.6
condition n/a
subroutine 6 9 66.6
pod 2 4 50.0
total 28 46 60.8


line stmt bran cond sub pod time code
1             package Database::Async::Engine;
2              
3 2     2   15 use strict;
  2         5  
  2         65  
4 2     2   11 use warnings;
  2         5  
  2         144  
5              
6             our $VERSION = '0.016'; # VERSION
7              
8 2     2   14 use parent qw(IO::Async::Notifier);
  2         3  
  2         12  
9              
10             =head1 NAME
11              
12             Database::Async::Engine - base class for database implementation support in L
13              
14             =head1 DESCRIPTION
15              
16             =cut
17              
18 2     2   191 use URI;
  2         5  
  2         65  
19 2     2   11 use Scalar::Util;
  2         3  
  2         674  
20              
21             our %ENGINE_MAP;
22              
23             UNITCHECK { require Database::Async::Engine::Empty }
24              
25             =head2 register_class
26              
27             Class method which will register a package name for a given engine type.
28              
29             =cut
30              
31             sub register_class {
32 2     2 1 6 my ($self, $name, $engine_class) = @_;
33 2 50       11 die 'already have handler for ' . $name if exists $ENGINE_MAP{$name};
34 2         7 $ENGINE_MAP{$name} = $engine_class;
35 2         6 return;
36             }
37              
38 0     0 0   sub uri { shift->{uri} }
39 0     0 0   sub db { shift->{db} }
40              
41             sub configure {
42 0     0 1   my ($self, %args) = @_;
43 0           for (qw(uri)) {
44 0 0         $self->{$_} = URI->new('' . delete($args{$_})) if exists $args{$_};
45             }
46 0           for (qw(db)) {
47 0 0         Scalar::Util::weaken($self->{$_} = delete $args{$_}) if exists $args{$_};
48             }
49 0           $self->next::method(%args);
50             }
51              
52             1;
53              
54             =head1 AUTHOR
55              
56             Tom Molesworth C<< >>
57              
58             =head1 LICENSE
59              
60             Copyright Tom Molesworth 2011-2021. Licensed under the same terms as Perl itself.
61