9c7ac7b26256909eaf00187a073ab588ce72dc42
[scpubgit/Object-Remote.git] / lib / Object / Remote / Role / Connector.pm
1 package Object::Remote::Role::Connector;
2
3 use Object::Remote::Connection;
4 use Moo::Role;
5
6 requires '_open2_for';
7
8 sub connect {
9   my $self = shift;
10   my %args;
11   @args{qw(send_to_fh receive_from_fh child_pid)} = $self->_open2_for(@_);
12   my $line = readline($args{receive_from_fh});
13   unless ($line eq "Shere\n") {
14     die "New remote container did not send Shere - got ${line}";
15   }
16   return Object::Remote::Connection->new(\%args);
17 }
18
19 1;