X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FObject%2FRemote%2FConnection.pm;h=da80bac8ae2f4b8e559cb512edb86a7c2d0b70c7;hb=a6786ddab559c869f448c1cb963e83faeb5efd40;hp=21bcec455061ad756157128644a3f72fc3b4d36b;hpb=12fb4a80d68ad14c18a35f60cc6d8a671f728ac9;p=scpubgit%2FObject-Remote.git diff --git a/lib/Object/Remote/Connection.pm b/lib/Object/Remote/Connection.pm index 21bcec4..da80bac 100644 --- a/lib/Object/Remote/Connection.pm +++ b/lib/Object/Remote/Connection.pm @@ -104,6 +104,10 @@ sub _build__json { tie *$handle, 'Object::Remote::GlobProxy', $glob_container; return $handle; } + )->filter_json_single_key_object( + __local_object__ => sub { + $self->local_objects_by_id->{$_[0]} + } ); } @@ -119,7 +123,9 @@ sub new_from_spec { my ($class, $spec) = @_; return $spec if blessed $spec; foreach my $poss (do { our @Guess }) { - if (my $obj = $poss->($spec)) { return $obj } + if (my $conn = $poss->($spec)) { + return $conn->maybe::start::connect; + } } die "Couldn't figure out what to do with ${spec}"; } @@ -241,7 +247,14 @@ sub _local_object_to_id { sub _deobjectify { my ($self, $data) = @_; if (blessed($data)) { - return +{ __remote_object__ => $self->_local_object_to_id($data) }; + if ( + $data->isa('Object::Remote::Proxy') + and $data->{remote}->connection == $self + ) { + return +{ __local_object__ => $data->{remote}->id }; + } else { + 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 };