From: Matt S Trout Date: Wed, 6 Jun 2012 18:02:38 +0000 (+0000) Subject: get_remote_sub X-Git-Tag: v0.001001~28 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FObject-Remote.git;a=commitdiff_plain;h=c6fe6fbd88a05e860ecdc8942cb86940915172ed get_remote_sub --- diff --git a/lib/Object/Remote/Connection.pm b/lib/Object/Remote/Connection.pm index a5ad302..3e35d53 100644 --- a/lib/Object/Remote/Connection.pm +++ b/lib/Object/Remote/Connection.pm @@ -106,6 +106,12 @@ sub new_remote { )->proxy; } +sub get_remote_sub { + my ($self, $sub) = @_; + my ($pkg, $name) = $sub =~ m/^(.*)::([^:]+)$/; + return await_future($self->send(class_call => $pkg, 0, can => $name)); +} + sub register_remote { my ($self, $remote) = @_; weaken($self->remote_objects_by_id->{$remote->id} = $remote); diff --git a/t/basic.t b/t/basic.t index 24913dc..4529e55 100644 --- a/t/basic.t +++ b/t/basic.t @@ -1,5 +1,6 @@ use strictures 1; use Test::More; +use Sys::Hostname qw(hostname); use Object::Remote::Connector::Local; use Object::Remote; @@ -31,4 +32,10 @@ is($remote->call_callback(27, sub { $x++ }), 27, "Callback ok"); is($x, 1, "Callback called callback"); +is( + $connection->get_remote_sub('Sys::Hostname::hostname')->(), + hostname(), + 'Remote sub call ok' +); + done_testing;