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