blib/lib/QWizard/Storage/CGIParam.pm

filter: Statementstmt 77.7% 7 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 83.3% 10 / 12 CC 1 SCAR 0.9
CC
1
Cov
78%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« blib/lib/QWizard/Storage/CGICookie.pm ↑ Summary blib/lib/QWizard/Storage/Memory.pm »
1 package QWizard::Storage::CGIParam;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use QWizard::Storage::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 our @ISA = qw(QWizard::Storage::Base);
6  
7 our $VERSION = '3.15';
8 0 ▶use CGI;
Subroutine BEGIN: called CC=1 SCAR=2.6
9  
10 our %cached_params = ();
11  
12 sub new {
13 my $class = shift;
14 bless {}, $class;
15 }
16  
17 sub maybe_create_cgi {
18 my $self = shift;
19 if (!exists($self->{'cgi'})) {
20 # we do this here late binding as possible for various reasons
21 $self->{'cgi'} = new CGI;
22 }
23 }
24  
25 sub get {
26 my ($self, $it) = @_;
27 $self->maybe_create_cgi();
28 return $cached_params{$it} if (exists($cached_params{$it}));
29 return $self->{'cgi'}->param($it);
30 }
31  
32 sub set {
33 my ($self, $it, $val) = @_;
34 $self->maybe_create_cgi();
35 return $self->{'cgi'}->param($it, $val);
36 }
37  
38 sub get_all {
39 my ($self) = @_;
40 my %ret;
41 my @names = $self->{'cgi'}->param;
42 map { $ret{$_} = $self->{'cgi'}->param($_) } @names;
43 return \%ret;
44 }
45  
46 sub reset {
47 my ($self) = @_;
48 $self->maybe_create_cgi();
49 $self->{'cgi'}->delete_all();
50 %cached_params = ();
51 }
52  
53 1;
54  
55 =pod
56  
57 =head1 NAME
58  
59 QWizard::Storage::CGIParam - Stores data in CGI variables
60  
61 =head1 SYNOPSIS
62  
63 my $st = new QWizard::Storage::CGIParam();
64 $st->set('var', 'value');
65 $st->get('var');
66  
67 =head1 DESCRIPTION
68  
69 Stores data passed to it inside of CGI parameters.
70  
71 =head1 AUTHOR
72  
73 Wes Hardaker, hardaker@users.sourceforge.net
74  
75 =head1 SEE ALSO
76  
77 perl(1)
78  
79 Net-Policy: http://net-policy.sourceforge.net/
80  
81 =cut
« blib/lib/QWizard/Storage/CGICookie.pm ↑ Summary blib/lib/QWizard/Storage/Memory.pm »