From: Matt S Trout Date: Mon, 15 Oct 2012 11:47:51 +0000 (+0000) Subject: add __local_object__ X-Git-Tag: v0.003001_01~121 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6163a5aa713c3e27a6c6cd4060e20b556dbef269;p=scpubgit%2FObject-Remote.git add __local_object__ --- diff --git a/lib/Object/Remote/Connection.pm b/lib/Object/Remote/Connection.pm index ed78e0e..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]} + } ); } @@ -243,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 }; diff --git a/t/lib/ORTestObjects.pm b/t/lib/ORTestObjects.pm index 0e2195c..28bbf52 100644 --- a/t/lib/ORTestObjects.pm +++ b/t/lib/ORTestObjects.pm @@ -19,7 +19,6 @@ sub give_back { sub takes_object { my ($self, $object) = @_; - print STDERR ref($object); if($object->isa('ORTestObjects')) { return 1; }