File Coverage

blib/lib/JOAP/Proxy/Package.pm
Criterion Covered Total %
statement 16 18 88.8
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 22 24 91.6


line stmt bran cond sub pod time code
1             # JOAP::Proxy::Package -- Classes that use JOAP
2             #
3             # Copyright (c) 2003, Evan Prodromou
4             #
5             # This library is free software; you can redistribute it and/or
6             # modify it under the terms of the GNU Lesser General Public
7             # License as published by the Free Software Foundation; either
8             # version 2.1 of the License, or (at your option) any later version.
9             #
10             # This library is distributed in the hope that it will be useful,
11             # but WITHOUT ANY WARRANTY; without even the implied warranty of
12             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13             # Lesser General Public License for more details.
14             #
15             # You should have received a copy of the GNU Lesser General Public
16             # License along with this library; if not, write to the Free Software
17             # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18              
19             # tag: JOAP package base class
20              
21             package JOAP::Proxy::Package;
22 1     1   2807 use Class::Data::Inheritable;
  1         2  
  1         38  
23 1     1   6 use base qw/Exporter Class::Data::Inheritable/;
  1         3  
  1         166  
24              
25 1     1   31 use 5.008;
  1         4  
  1         46  
26 1     1   5 use strict;
  1         2  
  1         48  
27 1     1   5 use warnings;
  1         2  
  1         31  
28 1     1   587 use JOAP::Proxy::Error;
  0            
  0            
29              
30             our %EXPORT_TAGS = ( 'all' => [ qw// ] );
31             our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
32             our @EXPORT = qw//;
33              
34             our $VERSION = $JOAP::VERSION;
35             our $AUTOLOAD;
36              
37             JOAP::Proxy::Package->mk_classdata('Attributes');
38             JOAP::Proxy::Package->mk_classdata('Methods');
39             JOAP::Proxy::Package->mk_classdata('Timestamp');
40             JOAP::Proxy::Package->mk_classdata('Description');
41              
42             JOAP::Proxy::Package->Methods({});
43             JOAP::Proxy::Package->Attributes({});
44             JOAP::Proxy::Package->Timestamp(undef);
45             JOAP::Proxy::Package->Description('');
46              
47             # when describe stuff happens, we want to store it in the package
48             # rather than in the instance.
49              
50             sub attributes {
51             my $self = shift;
52             return $self->Attributes(@_);
53             }
54              
55             sub methods {
56             my $self = shift;
57             return $self->Methods(@_);
58             }
59              
60             sub timestamp {
61             my $self = shift;
62             return $self->Timestamp(@_);
63             }
64              
65             sub _set_timestamp {
66             my $self = shift;
67             return $self->Timestamp(@_);
68             }
69              
70             sub description {
71             my $self = shift;
72             return $self->Description(@_);
73             }
74              
75             sub _set_description {
76             my $self = shift;
77             return $self->Description(@_);
78             }
79              
80             # when we autoload, we want to cache the results in the package
81             # namespace.
82              
83             sub AUTOLOAD {
84              
85             my ($self) = $_[0];
86             my ($sub) = $AUTOLOAD;
87              
88             my ($pkg,$name) = ($sub =~ /(.*)::([^:]+)$/);
89             my ($func) = $self->can($name);
90              
91             if ($func) {
92             no strict 'refs';
93             *$sub = $func;
94             goto &$sub;
95             } else {
96             throw JOAP::Proxy::Error::Local("No attribute or method '$name'");
97             }
98             }
99              
100             1;
101             __END__