lib/WWW/Hetzner/Role/HasActions.pm

filter: Statementstmt 100% 25 / 25 Branchbran 100% 4 / 4 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 100% 39 / 39 CC 4 SCAR 4.7
CC
4
Cov
100%
_wrap_action
2.0
_wrap_actions
2.0
_wrap_action_result
2.0
CRAP 1.6
« lib/WWW/Hetzner/Robot/API/Failover.pm ↑ Summary lib/WWW/Hetzner/Storage/API/Actions.pm »
1 package WWW::Hetzner::Role::HasActions;
2 # ABSTRACT: Controller role wrapping raw hashes as Action objects
3  
4 60 our $VERSION = '0.102';
5  
6 60 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 60 ▶use WWW::Hetzner::Action;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 60 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 60 requires 'client';
12  
13 has action_poll_path => (
14 is => 'ro',
15 347 ▶ default => sub { '/actions' },
Subroutine __ANON__: called CC=1 SCAR=0.0
16 60 );
17  
18  
19 194 ▶sub _wrap_action {
Subroutine _wrap_action: called CC=2 SCAR=6.9
20 194 my ($self, $data) = @_;
21 194 ▶ return defined $data
Branch: 1 branch
BranchTrueFalseTotal
defined $data ? : 191 3 194
22 ? WWW::Hetzner::Action->new(
23 client => $self->client,
24 %$data,
25 poll_path => $self->action_poll_path,
26 )
27 : undef;
28 }
29  
30  
31 45 ▶sub _wrap_actions {
Subroutine _wrap_actions: called CC=2 SCAR=6.9
32 45 my ($self, $list) = @_;
33 45 ▶ return [ map { $self->_wrap_action($_) } @{ $list // [] } ];
Condition100%2/2
$list // []
l!l
3510
MC/DC100%1/1
$list // []
$list
Truth table100%2/2
A
A= $list
Aresult
11
00
34 }
35  
36  
37 11 ▶sub _wrap_action_result {
Subroutine _wrap_action_result: called CC=2 SCAR=6.9
38 11 my ($self, $result) = @_;
39 11 my %sidecar = %$result;
40 11 my $action = delete $sidecar{action};
41 11 ▶ return undef unless defined $action;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $action 1 10 11
42 10 WWW::Hetzner::Action->new(
43 client => $self->client,
44 %$action,
45 result => \%sidecar,
46 poll_path => $self->action_poll_path,
47 );
48 }
49  
50  
51  
52 60 1;
53  
54 __END__
« lib/WWW/Hetzner/Robot/API/Failover.pm ↑ Summary lib/WWW/Hetzner/Storage/API/Actions.pm »