| 1 | package Tak::ObjectService; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 1 | ▶ | use overload (); | ||||||||||||
|
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::Service'; | ||||||||||||||
| 7 | with 'Tak::Role::ObjectMangling'; | ||||||||||||||
| 8 | |||||||||||||||
| 9 | has proxied => (is => 'ro', init_arg => undef, default => sub { {} }); | ||||||||||||||
| 10 | |||||||||||||||
| 11 | sub inflate { | ||||||||||||||
| 12 | 0 | ▶ | my ($self, $tag) = @_; | ||||||||||||
|
Subroutine
inflate: not called CC=1 SCAR=6.9
| |||||||||||||||
| 13 | 0 | $self->proxied->{$tag}; | |||||||||||||
| 14 | } | ||||||||||||||
| 15 | |||||||||||||||
| 16 | sub deflate { | ||||||||||||||
| 17 | 0 | ▶ | my ($self, $obj) = @_; | ||||||||||||
|
Subroutine
deflate: not called CC=1 SCAR=6.9
| |||||||||||||||
| 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 | ▶ | my ($self, $context, $call) = @_; | ||||||||||||
|
Subroutine
handle_call_method: not called CC=5 SCAR=34.0
| |||||||||||||||
| 25 | 0 | my ($invocant, $method, @args) = @{$self->decode_objects($call)}; | |||||||||||||
| 26 | 0 | my @res; | |||||||||||||
| 27 | 0 | ▶ | eval { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 28 | 0 | ▶ | if (!ref($invocant)) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 29 | 0 | (my $file = $invocant) =~ s/::/\//g; | |||||||||||||
| 30 | 0 | require "${file}.pm"; | |||||||||||||
| 31 | } | ||||||||||||||
| 32 | 0 | ▶ | if ($context) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 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 | ▶ | my ($self, $tag) = @_; | ||||||||||||
|
Subroutine
handle_remove_object: not called CC=1 SCAR=6.9
| |||||||||||||||
| 46 | 0 | my $had = !!delete $self->proxied->{$tag}; | |||||||||||||
| 47 | 0 | return $had; | |||||||||||||
| 48 | } | ||||||||||||||
| 49 | |||||||||||||||
| 50 | 1; | ||||||||||||||