Tak/ObjectClient.pm

filter: Statementstmt 20.0% 6 / 30 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 25.0% 2 / 8 Podpod n/a totaltotal 18.1% 8 / 44 SCAR 25.8
CC
4
Cov
17%
proxy_method_call
12.0
deflate
6.0
_build_object_service
2.0
CRAP 13.3
« Tak/ObjectService.pm ↑ Summary Tak/Router.pm »
1 package Tak::ObjectClient;
2  
3 1 ▶use Tak::ObjectProxy;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 with 'Tak::Role::ObjectMangling';
7  
8 has remote => (is => 'ro', required => 1);
9  
10 has object_service => (is => 'lazy');
11  
12 sub _build_object_service {
13 0 ▶ my ($self) = @_;
Subroutine _build_object_service: not called CC=1 SCAR=6.9
14 0 my $remote = $self->remote;
15 0 $remote->ensure(object_service => 'Tak::ObjectService');
16 0 $remote->curry('object_service');
17 }
18  
19 sub proxy_method_call {
20 0 ▶ my ($self, @call) = @_;
Subroutine proxy_method_call: not called CC=3 SCAR=24.8
21 0 my $client = $self->object_service;
22 0 my $ready = $self->encode_objects(\@call);
23 0 my $context = wantarray;
24 0 my $res = $client->do(call_method => $context => $ready);
25 0 my $unpacked = $self->decode_objects($res);
26 0 ▶ if ($context) {
Branch: 2 branches
BranchTrueFalseTotal
if ($context) { } 0 0 0
elsif (defined $context) { } 0 0 0
27 0 return @$unpacked;
28 } elsif (defined $context) {
29 0 return $unpacked->[0];
30 } else {
31 0 return;
32 }
33 }
34  
35 sub proxy_death {
36 0 ▶ my ($self, $proxy) = @_;
Subroutine proxy_death: not called CC=1 SCAR=6.9
37 0 $self->client->do(remove_object => $proxy->{tag});
38 }
39  
40 sub inflate {
41 0 ▶ my ($self, $tag) = @_;
Subroutine inflate: not called CC=1 SCAR=6.9
42 0 bless({ client => $self, tag => $tag }, 'Tak::ObjectProxy');
43 }
44  
45 sub deflate {
46 0 ▶ my ($self, $obj) = @_;
Subroutine deflate: not called CC=2 SCAR=17.9
47 0 ▶ unless (ref($obj) eq 'Tak::ObjectProxy') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $obj eq "Tak::ObjectProxy") 0 0 0
48 0 die "Can't deflate non-proxied object ${obj}";
49 }
50 0 return +{ __proxied_object__ => $obj->{tag} };
51 }
52  
53 sub new_object {
54 0 ▶ my ($self, $class, @args) = @_;
Subroutine new_object: not called CC=1 SCAR=6.9
55 0 $self->proxy_method_call($class, 'new', @args);
56 }
57  
58 1;
« Tak/ObjectService.pm ↑ Summary Tak/Router.pm »