1 package Tak::ObjectClient;
6 with 'Tak::Role::ObjectMangling';
8 has remote => (is => 'ro', required => 1);
10 has object_service => (is => 'lazy');
12 sub _build_object_service {
14 my $remote = $self->remote;
15 $remote->ensure(object_service => 'Tak::ObjectService');
16 $remote->curry('object_service');
19 sub proxy_method_call {
20 my ($self, @call) = @_;
21 my $client = $self->object_service;
22 my $ready = $self->encode_objects(\@call);
23 my $context = wantarray;
24 my $res = $client->do(call_method => $context => $ready);
25 my $unpacked = $self->decode_objects($res);
28 } elsif (defined $context) {
29 return $unpacked->[0];
36 my ($self, $proxy) = @_;
37 $self->client->do(remove_object => $proxy->{tag});
41 my ($self, $tag) = @_;
42 bless({ client => $self, tag => $tag }, 'Tak::ObjectProxy');
46 my ($self, $obj) = @_;
47 unless (ref($obj) eq 'Tak::ObjectProxy') {
48 die "Can't deflate non-proxied object ${obj}";
50 return +{ __proxied_object__ => $obj->{tag} };
54 my ($self, $class, @args) = @_;
55 $self->proxy_method_call($class, 'new', @args);