File Coverage

blib/lib/Lim/RPC/Transport.pm
Criterion Covered Total %
statement 39 48 81.2
branch 4 8 50.0
condition 3 9 33.3
subroutine 9 16 56.2
pod 10 10 100.0
total 65 91 71.4


line stmt bran cond sub pod time code
1             package Lim::RPC::Transport;
2              
3 3     3   12070 use common::sense;
  3         10  
  3         24  
4 3     3   168 use Carp;
  3         7  
  3         257  
5              
6 3     3   22 use Scalar::Util qw(blessed weaken);
  3         12  
  3         259  
7 3     3   21 use Log::Log4perl ();
  3         6  
  3         52  
8              
9 3     3   304 use Lim ();
  3         121  
  3         2967  
10              
11             =encoding utf8
12              
13             =head1 NAME
14              
15             ...
16              
17             =head1 VERSION
18              
19             See L for version.
20              
21             =cut
22              
23             our $VERSION = $Lim::VERSION;
24              
25             =head1 SYNOPSIS
26              
27             ...
28              
29             =head1 SUBROUTINES/METHODS
30              
31             =head2 new
32              
33             =cut
34              
35             sub new {
36 2     2 1 6 my $this = shift;
37 2   33     15 my $class = ref($this) || $this;
38 2         15 my %args = ( @_ );
39 2         21 my $self = {
40             logger => Log::Log4perl->get_logger,
41             __protocols => []
42             };
43 2         1602 bless $self, $class;
44              
45 2 50 33     41 unless (blessed($args{server}) and $args{server}->isa('Lim::RPC::Server')) {
46 0         0 confess __PACKAGE__, ': No server specified or invalid';
47             }
48 2         27 $self->{__server} = $args{server};
49 2         12 weaken($self->{__server});
50            
51 2         14 $self->Init(@_);
52              
53 2 50       184 Lim::OBJ_DEBUG and $self->{logger}->debug('new ', __PACKAGE__, ' ', $self);
54 2         1306 $self;
55             }
56              
57             sub DESTROY {
58 2     2   7 my ($self) = @_;
59 2 50       12 Lim::OBJ_DEBUG and $self->{logger}->debug('destroy ', __PACKAGE__, ' ', $self);
60            
61 2         2190 $self->Destroy;
62 2         130 delete $self->{__protocols};
63 2         1100 delete $self->{__server};
64             }
65              
66             =head2 Init
67              
68             =cut
69              
70 0     0 1 0 sub Init {
71             }
72              
73             =head2 Destroy
74              
75             =cut
76              
77 0     0 1 0 sub Destroy {
78             }
79              
80             =head2 name
81              
82             =cut
83              
84             sub name {
85 0     0 1 0 confess 'function name not overloaded';
86             }
87              
88             =head2 uri
89              
90             =cut
91              
92             sub uri {
93 0     0 1 0 confess 'function uri not overloaded';
94             }
95              
96             =head2 add_protocol
97              
98             =cut
99              
100             sub add_protocol {
101 2     2 1 6 my $self = shift;
102            
103 2         8 foreach (@_) {
104 2 50 33     54 unless (blessed($_) and $_->isa('Lim::RPC::Protocol')) {
105 0         0 confess 'Argument is not a Lim::RPC::Protocol';
106             }
107             }
108 2         6 push(@{$self->{__protocols}}, @_);
  2         7  
109            
110 2         8 $self;
111             }
112              
113             =head2 protocols
114              
115             =cut
116              
117             sub protocols {
118 2     2 1 6 @{$_[0]->{__protocols}};
  2         16  
119             }
120              
121             =head2 server
122              
123             =cut
124              
125             sub server {
126 0     0 1   $_[0]->{__server};
127             }
128              
129             =head2 host
130              
131             =cut
132              
133             sub host {
134 0     0 1   confess 'function host not overloaded';
135             }
136              
137             =head2 port
138              
139             =cut
140              
141             sub port {
142 0     0 1   confess 'function port not overloaded';
143             }
144              
145             =head1 AUTHOR
146              
147             Jerry Lundström, C<< >>
148              
149             =head1 BUGS
150              
151             Please report any bugs or feature requests to L.
152              
153             =head1 SUPPORT
154              
155             You can find documentation for this module with the perldoc command.
156              
157             perldoc Lim
158              
159             You can also look for information at:
160              
161             =over 4
162              
163             =item * Lim issue tracker (report bugs here)
164              
165             L
166              
167             =back
168              
169             =head1 ACKNOWLEDGEMENTS
170              
171             =head1 LICENSE AND COPYRIGHT
172              
173             Copyright 2012-2013 Jerry Lundström.
174              
175             This program is free software; you can redistribute it and/or modify it
176             under the terms of either: the GNU General Public License as published
177             by the Free Software Foundation; or the Artistic License.
178              
179             See http://dev.perl.org/licenses/ for more information.
180              
181              
182             =cut
183              
184             1; # End of Lim::RPC::Transport