blib/lib/DBIO/Replicated/Backend.pm

filter: Statementstmt 100% 44 / 44 Branchbran 72.2% 13 / 18 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 90.9% 10 / 11 Podpod 100% 4 / 4 totaltotal 90.0% 72 / 80 CC 11 SCAR 9.8
CC
11
Cov
91%
AUTOLOAD
4.2
new
4.0
master
3.0
CRAP 2.7
« blib/lib/DBIO/Test/Schema/Artwork.pm ↑ Summary blib/lib/DBIO/DeploymentHandler/HandlesDeploy.pm »
1 package DBIO::Replicated::Backend;
2 # ABSTRACT: Wrapper base class for replicated backends
3  
4 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 18 our $VERSION = '0.900007';
8  
9 18 ▶use base 'DBIO::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 18 ▶use Scalar::Util 'weaken';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 18 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 18 our $AUTOLOAD;
14  
15 18 __PACKAGE__->mk_group_accessors(simple => qw/
16 storage
17 dsn
18 id
19 active
20 kind
21 /);
22  
23  
24 94 ▶sub new {
Subroutine new: called CC=4 SCAR=13.9
Pod documented
25 94 my ($class, %args) = @_;
26  
27 my $self = bless {
28 storage => $args{storage},
29 dsn => $args{dsn},
30 id => $args{id},
31 active => exists $args{active} ? $args{active} : 1,
32 94 ▶ kind => $args{kind} || 'backend',
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'active'} ? : 49 45 94
Condition50%1/2
$args{'kind'} || 'backend'
l!l
940
MC/DC0%0/1
$args{'kind'} || 'backend'
$args{'kind'}
Truth table50%1/2
A
A= $args{'kind'}
Aresult
11
00
33 }, $class;
34  
35 94 ▶ $self->master($args{master}) if exists $args{master};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"master"} 46 48 94
36  
37 94 return $self;
38 }
39  
40  
41 47 ▶sub master {
Subroutine master: called CC=3 SCAR=11.0
Pod documented
42 47 my $self = shift;
43 47 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 46 1 47
44 46 $self->{master} = $_[0];
45 46 ▶ weaken $self->{master} if ref $self->{master};
Branch: 1 branch
BranchTrueFalseTotal
if ref $self->{"master"} 46 0 46
46 }
47 47 return $self->{master};
48 }
49  
50  
51 104 ▶sub install_debug_proxy {
Subroutine install_debug_proxy: called CC=2 SCAR=6.9
Pod documented
52 104 my ($self, $target) = @_;
53 104 require DBIO::Replicated::DebugProxy;
54  
55 104 ▶ if (eval { $target->isa('DBIO::Replicated::DebugProxy') }) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { $target->isa("DBIO::Replicated::DebugProxy") } }) 60 44 104
56 60 $target = $target->target;
57 }
58  
59 $self->storage->debugobj(
60 104 DBIO::Replicated::DebugProxy->new(
61 backend => $self,
62 target => $target,
63 )
64 );
65 }
66  
67  
68 1 ▶sub debugobj {
Subroutine debugobj: called CC=2 SCAR=7.1
Pod documented
69 1 my $self = shift;
70 1 ▶ return $self->storage->debugobj(@_) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 1 1
71 1 return $self->storage->debugobj;
72 }
73  
74 176 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=4 SCAR=14.3
75 176 my $self = shift;
76 176 my ($method) = $AUTOLOAD =~ /::([^:]+)\z/;
77 176 ▶ return if $method eq 'DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $method eq "DESTROY" 0 176 176
78  
79 176 ▶ my $storage = $self->storage
Branch: 1 branch
BranchTrueFalseTotal
my $storage = $self->storage or $self->throw_exception("No wrapped storage available for $method()") 176 0 176
80 or $self->throw_exception("No wrapped storage available for $method()");
81  
82 176 ▶ my $code = $storage->can($method)
Branch: 1 branch
BranchTrueFalseTotal
my $code = $storage->can($method) or $self->throw_exception(ref($storage) . " does not implement $method()") 176 0 176
83 or $self->throw_exception(ref($storage) . " does not implement $method()");
84  
85 176 unshift @_, $storage;
86 176 goto &$code;
87 }
88  
89 0 ▶sub DESTROY { }
Subroutine DESTROY: not called CC=1 SCAR=0.0
90  
91 18 1;
92  
93 __END__
« blib/lib/DBIO/Test/Schema/Artwork.pm ↑ Summary blib/lib/DBIO/DeploymentHandler/HandlesDeploy.pm »