File Coverage

blib/lib/XPlanner/Object.pm
Criterion Covered Total %
statement 3 15 20.0
branch 0 2 0.0
condition n/a
subroutine 1 3 33.3
pod n/a
total 4 20 20.0


line stmt bran cond sub pod time code
1             package XPlanner::Object;
2              
3 2     2   22 use strict;
  2         3  
  2         473  
4              
5              
6             =head1 NAME
7              
8             XPlanner::Object - Base class for all XPlanner objects
9              
10             =head1 SYNOPSIS
11              
12             # No user servicable parts inside. Go away
13              
14             =begin private
15              
16             package XPlanner::Foo;
17             use base 'XPlanner::Object';
18              
19              
20             =head1 DESCRIPTION
21              
22             A place to put methods common to all XPlanner objects
23              
24             =head2 Methods
25              
26             =head3 _map_from_soap
27              
28             my $mapped_objects = $self->_map_from_soap($key, $proxy_method, $class);
29              
30             Loads the given $class we want to map these objects to and calls the
31             given $proxy_method on the SOAP proxy to get them. It then translates the
32             list of objects into a hash keyed on $key from inside each object.
33              
34             The SOAP proxy will be put into each object.
35              
36             Equivalent to
37              
38             eval "require $class";
39             my %mapped_objects = map { $_->{_proxy} = $self;
40             $_->{$key} => $_
41             } @{$proxy->$proxy_method($self->{id})->result};
42              
43             =cut
44              
45             sub _map_from_soap {
46 0     0     my($self, $key, $proxy_method, $class) = @_;
47 0           my $proxy = $self->{_proxy};
48              
49             # Everything has an id except for the project itself.
50 0           my @proxy_args;
51 0 0         @proxy_args = $self->{id} unless $self->isa('XPlanner');
52              
53 0           eval "require $class";
54 0           my %mapped_objects = map { $_->{_proxy} = $self->{_proxy};
  0            
55 0           $_->{$key} => $_
56 0           } @{$proxy->$proxy_method(@proxy_args)->result};
57              
58 0           return \%mapped_objects;
59             }
60              
61              
62             sub _init {
63 0     0     my($class, %args) = @_;
64              
65 0           bless \%args, $class->_proxy_class;
66             }
67              
68              
69             1;