use JSON::PP qw(encode_json);
use Moo;
-our $DEBUG;
+our $DEBUG = !!$ENV{OBJECT_REMOTE_DEBUG};
has send_to_fh => (
is => 'ro', required => 1,
BEGIN {
unshift our @Guess, sub { blessed($_[0]) ? $_[0] : undef };
eval { require Object::Remote::Connector::Local };
+ eval { require Object::Remote::Connector::LocalSudo };
eval { require Object::Remote::Connector::SSH };
}
};
}
+sub _local_object_to_id {
+ my ($self, $object) = @_;
+ my $id = refaddr($object);
+ $self->local_objects_by_id->{$id} ||= do {
+ push our(@New_Ids), $id;
+ $object;
+ };
+ return $id;
+}
+
sub _deobjectify {
my ($self, $data) = @_;
if (blessed($data)) {
- my $id = refaddr($data);
- $self->local_objects_by_id->{$id} ||= do {
- push our(@New_Ids), $id;
- $data;
- };
- return +{ __remote_object__ => $id };
+ return +{ __remote_object__ => $self->_local_object_to_id($data) };
} elsif (my $ref = ref($data)) {
if ($ref eq 'HASH') {
return +{ map +($_ => $self->_deobjectify($data->{$_})), keys %$data };