add can::on
[scpubgit/Object-Remote.git] / lib / Object / Remote.pm
CommitLineData
9e72f0cf 1package Object::Remote;
2
3use Object::Remote::MiniLoop;
676438a1 4use Object::Remote::Handle;
e144d525 5use Module::Runtime qw(use_module);
9e72f0cf 6
84b04178 7sub new::on {
8 my ($class, $on, @args) = @_;
4c17fea5 9 my $conn = __PACKAGE__->connect($on);
11dbd4a0 10 return $conn->remote_object(class => $class, args => \@args);
84b04178 11}
12
624b459b 13sub can::on {
14 my ($class, $on, $name) = @_;
15 my $conn = __PACKAGE__->connect($on);
16 return $conn->remote_sub(join('::', $class, $name));
17}
18
676438a1 19sub new {
20 shift;
21 Object::Remote::Handle->new(@_)->proxy;
9e72f0cf 22}
23
4c17fea5 24sub connect {
25 my ($class, $to) = @_;
26 use_module('Object::Remote::Connection')->new_from_spec($to);
27}
28
9e72f0cf 29sub current_loop {
30 our $Current_Loop ||= Object::Remote::MiniLoop->new
31}
32
9e72f0cf 331;