From: Matt S Trout Date: Sat, 2 Jun 2012 10:40:11 +0000 (+0000) Subject: factor out _local_object_to_id method X-Git-Tag: v0.001001~39 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a76f2f60f38f21af50f878ea9dbd7f0670edf9f3;p=scpubgit%2FObject-Remote.git factor out _local_object_to_id method --- diff --git a/lib/Object/Remote/Connection.pm b/lib/Object/Remote/Connection.pm index 1d21114..d0679c4 100644 --- a/lib/Object/Remote/Connection.pm +++ b/lib/Object/Remote/Connection.pm @@ -146,15 +146,20 @@ sub _serialize { }; } +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 };