lib/Magpie/Plugin/DBI.pm

filter: Statementstmt 87.5% 21 / 24 Branchbran 50.0% 4 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 76.3% 29 / 38 CC 6 SCAR 18.0
CC
6
Cov
76%
_connect_args
7.7
BEGIN
1.0
BEGIN
1.0
CRAP 6.0
« blib/lib/Magpie/Component.pm ↑ Summary blib/lib/Magpie/Event.pm »
1 package Magpie::Plugin::DBI;
2 2 $Magpie::Plugin::DBI::VERSION = '1.163200';
3 2 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 # ABSTRACT: A simple Role for dealing with DBI-backed assets;
6 #
7 2 ▶use Magpie::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 has dsn => (
10 isa => "Str",
11 is => "ro",
12 predicate => "has_dsn",
13 );
14  
15 2 has extra_args => (
16 isa => "HashRef|ArrayRef",
17 is => "ro",
18 predicate => "has_extra_args",
19 );
20  
21 2 has username => (
22 is => 'ro',
23 isa => 'Maybe[Str]',
24 predicate => 'has_username',
25 );
26  
27 2 has password => (
28 is => 'ro',
29 isa => 'Maybe[Str]',
30 predicate => 'has_password',
31 );
32  
33 1 ▶sub _connect_args {
Subroutine _connect_args: called CC=6 SCAR=20.5
34 1 my $self = shift;
35 1 ▶ my @args = ( $self->dsn || die "dsn is required" );
Condition50%1/2
$self->dsn || die('dsn is required')
l!l
10
MC/DC0%0/1
$self->dsn || die('dsn is required')
$self->dsn
Truth table50%1/2
A
A= $self->dsn
Aresult
11
00
36  
37 1 ▶ if ( $self->has_username ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_username) 0 1 1
38 0 push @args, user => $self->username;
39 }
40  
41 1 ▶ if ( $self->has_password ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_password) 0 1 1
42 0 push @args, password => $self->password;
43 }
44  
45 1 ▶ if ( $self->has_extra_args ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_extra_args) 1 0 1
46 1 my $extra = $self->extra_args;
47  
48 1 ▶ if ( ref($extra) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $extra eq 'ARRAY') { } 0 1 1
49 0 push @args, @$extra;
50 }
51 else {
52 1 push @args, %$extra;
53 }
54 }
55  
56 1 \@args;
57 }
58  
59  
60 2 1;
61  
62 __END__
« blib/lib/Magpie/Component.pm ↑ Summary blib/lib/Magpie/Event.pm »