c9193d0d3512669b35c7b1bc4861b3ba7d28128f
[scpubgit/Object-Remote.git] / lib / Object / Remote / Connector / SSH.pm
1 package Object::Remote::Connector::SSH;
2
3 use Object::Remote::FatNode;
4 use Net::OpenSSH;
5 use Moo;
6
7 with 'Object::Remote::Role::Connector';
8
9 has ssh_masters => (is => 'ro', default => sub { {} });
10
11 sub _open2_for {
12   my $self = shift;
13   my @res = $self->_ssh_object_for(@_)->open2('perl','-',@_);
14   print { $res[0] } $Object::Remote::FatNode::DATA, "__END__\n";
15   return @res;
16 }
17
18 sub _ssh_object_for {
19   my ($self, $on) = @_;
20   $self->ssh_masters->{$on} ||= Net::OpenSSH->new($on);
21 }
22
23 1;