Tak/Role/Service.pm

filter: Statementstmt 16.6% 4 / 24 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 25.0% 1 / 4 Podpod 0.0% 0 / 3 totaltotal 11.6% 5 / 43 SCAR 37.2
CC
7
Cov
11%
start_request
42.0
receive
6.0
clone_or_self
2.0
CRAP 41.4
« Tak/MetaService.pm ↑ Summary Tak/CommandService.pm »
1 package Tak::Role::Service;
2  
3 1 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 sub start_request {
6 0 ▶ my ($self, $req, $type, @payload) = @_;
Subroutine start_request: not called CC=6 SCAR=37.4
Pod undocumented
7 0 ▶ unless ($type) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($type) 0 0 0
8 0 $req->mistake(request_type => "No request type given");
9 0 return;
10 }
11 0 ▶ if (my $meth = $self->can("handle_${type}")) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $meth = $self->can("handle_$type")) { } 0 0 0
elsif ($meth = $self->can("start_${type}_request")) { } 0 0 0
12 0 my @result;
13 0 ▶ if (eval { @result = $self->$meth(@payload); 1 }) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { @result = $self->$meth(@payload); 1 } }) { } 0 0 0
14 0 $req->success(@result);
15 } else {
16 0 ▶ if (ref($@) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $@ eq 'ARRAY') { } 0 0 0
17 0 $req->result(@{$@});
18 } else {
19 0 $req->failure(exception => $@);
20 }
21 }
22 } elsif ($meth = $self->can("start_${type}_request")) {
23 0 $self->$meth($req => @payload);
24 } else {
25 0 $req->mistake(request_type => "Unknown request type ${type}");
26 }
27 }
28  
29 sub receive {
30 0 ▶ my ($self, $type, @payload) = @_;
Subroutine receive: not called CC=2 SCAR=17.9
Pod undocumented
31 0 ▶ if (my $meth = $self->can("receive_${type}")) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $meth = $self->can("receive_$type")) 0 0 0
32 0 $self->$meth(@payload);
33 }
34 }
35  
36 # This assumes that by default either services are not stateful
37 # or do want to have persistent state. It's notably overriden by Router.
38  
39 0 ▶sub clone_or_self { $_[0] }
Subroutine clone_or_self: not called CC=1 SCAR=6.9
Pod undocumented
40  
41 1 1;
« Tak/MetaService.pm ↑ Summary Tak/CommandService.pm »