factor out new_class_call_handler
Matt S Trout [Mon, 18 Jun 2012 01:16:40 +0000 (02:16 +0100)]
lib/Object/Remote/Connection.pm

index 94bea15..8f4d443 100644 (file)
@@ -129,17 +129,21 @@ sub send_class_call {
 sub register_class_call_handler {
   my ($self) = @_;
   $self->local_objects_by_id->{'class_call_handler'} ||= do {
-    my $o = Object::Remote::CodeContainer->new(
-      code => sub {
-        my ($class, $method) = (shift, shift);
-        use_module($class)->$method(@_);
-      }
-    );
+    my $o = $self->new_class_call_handler;
     $self->_local_object_to_id($o);
     $o;
   };
 }
 
+sub new_class_call_handler {
+  Object::Remote::CodeContainer->new(
+    code => sub {
+      my ($class, $method) = (shift, shift);
+      use_module($class)->$method(@_);
+    }
+  );
+}
+
 sub register_remote {
   my ($self, $remote) = @_;
   weaken($self->remote_objects_by_id->{$remote->id} = $remote);