File Coverage

blib/lib/SOAPjr/base.pm
Criterion Covered Total %
statement 9 46 19.5
branch 0 12 0.0
condition 0 4 0.0
subroutine 3 8 37.5
pod 0 4 0.0
total 12 74 16.2


line stmt bran cond sub pod time code
1             package SOAPjr::base;
2              
3 1     1   7 use strict;
  1         2  
  1         37  
4 1     1   5 use warnings;
  1         2  
  1         47  
5              
6             =head1 NAME
7              
8             SOAPjr::base - base class for SOAPjr objects
9              
10             =head1 VERSION
11              
12             Version 1.0.1
13              
14             =cut
15              
16             our $VERSION = "1.0.1";
17              
18             =head1 SYNOPSIS
19              
20             See perldoc SOAPjr for more info.
21              
22             =cut
23              
24 1     1   1323 use JSON;
  1         23546  
  1         6  
25             $JSON::UnMapping = 1;
26              
27             sub new {
28 0     0 0   my $self = {};
29 0           my $class = shift;
30 0           bless $self, $class;
31 0           $self->{_data} = {};
32 0           $self->{MOBject_structure} = {
33             ENVELOPE => 1,
34             BODY => 1,
35             HEAD => 1,
36             OPTIONS => 1
37             };
38 0           $self->{json} = JSON->new();
39 0           return $self->_init(@_);
40             }
41              
42             sub _init {
43 0     0     my $self = shift;
44 0           return $self;
45             }
46              
47             sub set {
48 0     0 0   my $self = shift;
49 0   0       my $input = shift || undef;
50 0           my $count = shift;
51              
52 0 0         if ($input) {
53 0           foreach my $structure ( keys %{ $self->{MOBject_structure} } ) {
  0            
54 0 0         if ( exists $input->{$structure} ) {
55 0 0         if (ref($input->{$structure}) eq 'HASH') {
56 0           foreach my $item ( keys %{ $input->{$structure} } ) {
  0            
57 0           $self->{_data}->{$structure}->{$item} =
58             $input->{$structure}->{$item};
59 0           $count++;
60             }
61             } else {
62 0           $self->{_data}->{$structure} = $input->{$structure};
63 0           $count++;
64             }
65             }
66             }
67             }
68              
69 0           return $count;
70             }
71              
72             sub get {
73 0     0 0   my $self = shift;
74 0   0       my $param = shift || undef;
75 0 0         if ($param) {
76 0 0         if ( $self->{_data}->{$param} ) {
77 0           return $self->{_data}->{$param};
78             } else {
79 0           return {};
80             }
81             } else {
82 0           return $self->{_data};
83             }
84             }
85              
86             sub set_all {
87 0     0 0   my $self = shift;
88 0           my $input = shift;
89 0 0         if ($input) {
90 0           $self->{_data} = $input;
91 0           return 1;
92             } else {
93 0           return 0;
94             }
95             }
96              
97             =head1 AUTHOR
98              
99             Rob Manson,
100              
101             =head1 BUGS
102              
103             Please report any bugs or feature requests to C, or through
104             the web interface at L. I will be notified, and then you'll
105             automatically be notified of progress on your bug as I make changes.
106              
107              
108              
109              
110             =head1 SUPPORT
111              
112             You can find documentation for this module with the perldoc command.
113              
114             perldoc SOAPjr
115              
116              
117             You can also look for information at:
118              
119             =over 4
120              
121             =item * SOAPjr.org
122              
123             L
124              
125             =item * RT: CPAN's request tracker
126              
127             L
128              
129             =item * AnnoCPAN: Annotated CPAN documentation
130              
131             L
132              
133             =item * CPAN Ratings
134              
135             L
136              
137             =item * Search CPAN
138              
139             L
140              
141             =back
142              
143             =head1 ACKNOWLEDGEMENTS
144              
145             See L for further information on related RFC's and specifications.
146              
147             =head1 COPYRIGHT & LICENSE
148              
149             Copyright 2008 Rob Manson, Sean McCarthy and http://SOAPjr.org, some rights reserved.
150              
151             This file is part of SOAPjr.
152              
153             SOAPjr is free software: you can redistribute it and/or modify
154             it under the terms of the GNU General Public License as published by
155             the Free Software Foundation, either version 3 of the License, or
156             (at your option) any later version.
157              
158             SOAPjr is distributed in the hope that it will be useful,
159             but WITHOUT ANY WARRANTY; without even the implied warranty of
160             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
161             GNU General Public License for more details.
162              
163             You should have received a copy of the GNU General Public License
164             along with SOAPjr. If not, see .
165              
166             =cut
167              
168             1;