File Coverage

blib/lib/Tak/ObjectService.pm
Criterion Covered Total %
statement 6 29 20.6
branch 0 8 0.0
condition n/a
subroutine 2 6 33.3
pod 0 4 0.0
total 8 47 17.0


line stmt bran cond sub pod time code
1             package Tak::ObjectService;
2              
3 1     1   1138 use overload ();
  1         2  
  1         21  
4 1     1   5 use Moo;
  1         2  
  1         6  
5              
6             with 'Tak::Role::Service';
7             with 'Tak::Role::ObjectMangling';
8              
9             has proxied => (is => 'ro', init_arg => undef, default => sub { {} });
10              
11             sub inflate {
12 0     0 0   my ($self, $tag) = @_;
13 0           $self->proxied->{$tag};
14             }
15              
16             sub deflate {
17 0     0 0   my ($self, $obj) = @_;
18 0           my $tag = overload::StrVal($obj);
19 0           $self->proxied->{$tag} = $obj;
20 0           return +{ __proxied_object__ => $tag };
21             }
22              
23             sub handle_call_method {
24 0     0 0   my ($self, $context, $call) = @_;
25 0           my ($invocant, $method, @args) = @{$self->decode_objects($call)};
  0            
26 0           my @res;
27 0 0         eval {
28 0 0         if (!ref($invocant)) {
29 0           (my $file = $invocant) =~ s/::/\//g;
30 0           require "${file}.pm";
31             }
32 0 0         if ($context) {
    0          
33 0           @res = $invocant->$method(@args);
34             } elsif (defined $context) {
35 0           $res[0] = $invocant->$method(@args);
36             } else {
37 0           $invocant->$method(@args);
38             }
39 0           1;
40             } or die [ failure => "$@" ];
41 0           return $self->encode_objects(\@res);
42             }
43              
44             sub handle_remove_object {
45 0     0 0   my ($self, $tag) = @_;
46 0           my $had = !!delete $self->proxied->{$tag};
47 0           return $had;
48             }
49              
50             1;