926f060d0bcc49578b97c26afbb940d0c5b0b0d5
[scpubgit/Object-Remote.git] / lib / Object / Remote / Connector / UNIX.pm
1 package Object::Remote::Connector::UNIX;
2
3 use IO::Socket::UNIX;
4 use Moo;
5
6 with 'Object::Remote::Role::Connector';
7
8 has socket_path => (is => 'ro', required => 1);
9
10 sub _open2_for {
11   my ($self) = @_;
12   my $path = $self->socket_path;
13   my $sock = IO::Socket::UNIX->new($path)
14     or die "Couldn't open socket ${path}: $!";
15   ($sock, $sock, undef);
16 }
17
18 no warnings 'once';
19
20 push @Object::Remote::Connection::Guess, sub { 
21   for ($_[0]) {
22     if (defined and !ref and /^(?:\.\/|\/)/) {
23       return __PACKAGE__->new(socket_path => $_[0]);
24     }
25   }
26   return;
27 };
28
29 1;