File Coverage

blib/lib/RPC/Serialized/Client.pm
Criterion Covered Total %
statement 26 26 100.0
branch 4 6 66.6
condition 2 5 40.0
subroutine 6 6 100.0
pod 0 1 0.0
total 38 44 86.3


line stmt bran cond sub pod time code
1             #
2             # $HeadURL: https://svn.oucs.ox.ac.uk/people/oliver/pub/librpc-serialized-perl/trunk/lib/RPC/Serialized/Client.pm $
3             # $LastChangedRevision: 1323 $
4             # $LastChangedDate: 2008-10-01 16:16:56 +0100 (Wed, 01 Oct 2008) $
5             # $LastChangedBy: oliver $
6             #
7             package RPC::Serialized::Client;
8             {
9             $RPC::Serialized::Client::VERSION = '1.123630';
10             }
11              
12 15     15   14745 use strict;
  15         32  
  15         574  
13 15     15   72 use warnings FATAL => 'all';
  15         33  
  15         689  
14              
15 15     15   80 use base 'RPC::Serialized';
  15         25  
  15         4426  
16              
17 15     15   101 use RPC::Serialized::Exceptions;
  15         43  
  15         113  
18              
19             our $AUTOLOAD;
20              
21             sub call {
22 19     19 0 41 my $self = shift;
23 19         41 my $call = shift;
24              
25             # this is where we would hack around with the RPC protocol
26             # although not the on-the-wire stuff, which is in Serialized.pm
27 19         312 $self->send( { CALL => $call, ARGS => \@_ } );
28 19         8485 my $reply = $self->recv;
29              
30 19 100       80 if ( $reply->{EXCEPTION} ) {
31 6         21 my $class = $reply->{EXCEPTION}->{CLASS};
32              
33 6 50 33     168 throw_proto 'Invalid or missing CLASS'
34             unless $class and $class =~ /^RPC::Serialized::X(::.+)?$/;
35              
36 6   50     36 my $message = $reply->{EXCEPTION}->{MESSAGE} || "";
37 6         353 $class->throw($message);
38             }
39              
40 13         5026 return $reply->{RESPONSE};
41             }
42              
43             sub AUTOLOAD {
44 19     19   50373 my $self = shift;
45              
46 19 50       95 throw_app 'Object method called on class'
47             unless ref($self);
48              
49 19         148 ( my $call = $AUTOLOAD ) =~ s/^.*:://;
50 19         96 $self->call( $call, @_ );
51             }
52              
53             1;
54