Session/Serialization/JSON.pm

filter: Statementstmt 100% 21 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 3 / 3 totaltotal 100% 31 / 31 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Session/Storage/Memcached.pm ↑ Summary Session/Serialization/Storable.pm »
1 package WWW::Session::Serialization::JSON;
2  
3 6 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 6 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 =head1 NAME
10  
11 WWW::Session::Serialization::JSON - Serialization engine for WWW::Session with JSON backend
12  
13 =head1 DESCRIPTION
14  
15 JSON serialization engine for WWW::Session objects
16  
17 =head1 VERSION
18  
19 Version 0.12
20  
21 =cut
22  
23 6 our $VERSION = '0.12';
24  
25  
26 =head1 SYNOPSIS
27  
28 This module handles serialization for WWW::Session objects
29  
30 The object implements two main methods : serialize() and expand()
31  
32 use WWW::Session::Serialization::JSON;
33  
34 my $serializer = WWW::Session::Serialization::JSON->new();
35 ...
36
37 $string = $serializer->serialize($structure);
38
39 ...
40 $structure = $serializer->expand($string);
41  
42 =head1 SUBROUTINES/METHODS
43  
44 =head2 new
45  
46 Creates a new WWW::Session::Serialization::JSON object
47  
48 Usage :
49  
50 my $serializer = WWW::Session::Serialization::JSON->new();
51
52 No arguments required.
53  
54 =cut
55  
56 9 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
57 9 my $class = shift;
58
59 9 my $self = {};
60
61 9 bless $self,$class;
62
63 9 return $self;
64 }
65  
66 =head2 serialize
67  
68 Serializes a structure and returns a string containing all the data
69  
70 =cut
71  
72 20 ▶sub serialize {
Subroutine serialize: called CC=1 SCAR=0.0
Pod documented
73 20 my ($self,$data) = @_;
74
75 20 return to_json($data);
76 }
77  
78  
79 =head2 expand
80  
81 Deserializes string and returns a structure containing all the data
82  
83 =cut
84 6 ▶sub expand {
Subroutine expand: called CC=1 SCAR=0.0
Pod documented
85 6 my ($self,$string) = @_;
86
87 6 return from_json($string);
88 }
89  
90 =head1 AUTHOR
91  
92 Gligan Calin Horea, C<< <gliganh at gmail.com> >>
93  
94 =head1 BUGS
95  
96 Please report any bugs or feature requests to C<bug-www-session at rt.cpan.org>, or through
97 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Session>. I will be notified, and then you'll
98 automatically be notified of progress on your bug as I make changes.
99  
100  
101  
102  
103 =head1 SUPPORT
104  
105 You can find documentation for this module with the perldoc command.
106  
107 perldoc WWW::Session::Serialization::JSON
108  
109  
110 You can also look for information at:
111  
112 =over 4
113  
114 =item * RT: CPAN's request tracker (report bugs here)
115  
116 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-Session>
117  
118 =item * AnnoCPAN: Annotated CPAN documentation
119  
120 L<http://annocpan.org/dist/WWW-Session>
121  
122 =item * CPAN Ratings
123  
124 L<http://cpanratings.perl.org/d/WWW-Session>
125  
126 =item * Search CPAN
127  
128 L<http://search.cpan.org/dist/WWW-Session/>
129  
130 =back
131  
132  
133 =head1 ACKNOWLEDGEMENTS
134  
135  
136 =head1 LICENSE AND COPYRIGHT
137  
138 Copyright 2012 Gligan Calin Horea.
139  
140 This program is free software; you can redistribute it and/or modify it
141 under the terms of either: the GNU General Public License as published
142 by the Free Software Foundation; or the Artistic License.
143  
144 See http://dev.perl.org/licenses/ for more information.
145  
146  
147 =cut
148  
149 6 1; # End of WWW::Session::Serialization::JSON
« Session/Storage/Memcached.pm ↑ Summary Session/Serialization/Storable.pm »