minor API cleanups
[scpubgit/Object-Remote.git] / lib / Object / Remote.pm
index 47f2906..fc6e955 100644 (file)
@@ -2,14 +2,12 @@ package Object::Remote;
 
 use Object::Remote::MiniLoop;
 use Object::Remote::Handle;
+use Module::Runtime qw(use_module);
 
 sub new::on {
   my ($class, $on, @args) = @_;
-  Object::Remote::Handle->new(
-    connection => $on,
-    class => $class,
-    args => \@args
-  )->proxy;
+  my $conn = __PACKAGE__->connect($on);
+  return $conn->remote_object(class => $class, args => \@args);
 }
 
 sub new {
@@ -17,6 +15,11 @@ sub new {
   Object::Remote::Handle->new(@_)->proxy;
 }
 
+sub connect {
+  my ($class, $to) = @_;
+  use_module('Object::Remote::Connection')->new_from_spec($to);
+}
+
 sub current_loop {
   our $Current_Loop ||= Object::Remote::MiniLoop->new
 }