| 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
Condition50%1/2
$args{'kind'} || 'backend'
MC/DC0%0/1
$args{'kind'} || 'backend'
$args{'kind'}
Truth table50%1/2
A
A= $args{'kind'}
| |||||||||||||||||||||
| 33 | }, $class; | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 94 | ▶ | $self->master($args{master}) if exists $args{master}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 44 | 46 | $self->{master} = $_[0]; | |||||||||||||||||||
| 45 | 46 | ▶ | weaken $self->{master} if ref $self->{master}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 176 | ▶ | my $storage = $self->storage | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 80 | or $self->throw_exception("No wrapped storage available for $method()"); | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 176 | ▶ | my $code = $storage->can($method) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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__ | ||||||||||||||||||||