INET connector
[scpubgit/Object-Remote.git] / lib / Object / Remote / Connector / UNIX.pm
index 614609a..99e9a44 100644 (file)
@@ -5,8 +5,11 @@ use Moo;
 
 with 'Object::Remote::Role::Connector';
 
+has socket_path => (is => 'ro', required => 1);
+
 sub _open2_for {
-  my ($self,$path) = @_;
+  my ($self) = @_;
+  my $path = $self->socket_path;
   my $sock = IO::Socket::UNIX->new($path)
     or die "Couldn't open socket ${path}: $!";
   ($sock, $sock, undef);
@@ -14,10 +17,11 @@ sub _open2_for {
 
 no warnings 'once';
 
-push @Object::Remote::Connection::Guess, sub { 
+push @Object::Remote::Connection::Guess, sub {
   for ($_[0]) {
     if (defined and !ref and /^(?:\.\/|\/)/) {
-      return __PACKAGE__->new->connect($_[0]);
+      my $socket = shift(@_);
+      return __PACKAGE__->new(@_, socket_path => $socket);
     }
   }
   return;