| 1 | ################################################################################ |
1 | ################################################################################ |
| 2 | # WeBWorK Online Homework Delivery System |
2 | # WeBWorK Online Homework Delivery System |
| 3 | # Copyright © 2000-2006 The WeBWorK Project, http://openwebwork.sf.net/ |
3 | # Copyright © 2000-2006 The WeBWorK Project, http://openwebwork.sf.net/ |
| 4 | # $CVSHeader: webwork2/lib/WeBWorK/Request.pm,v 1.5 2006/06/29 23:20:47 sh002i Exp $ |
4 | # $CVSHeader: webwork2/lib/WeBWorK/Request.pm,v 1.6 2006/06/30 18:47:09 sh002i Exp $ |
| 5 | # |
5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify it under |
6 | # This program is free software; you can redistribute it and/or modify it under |
| 7 | # the terms of either: (a) the GNU General Public License as published by the |
7 | # the terms of either: (a) the GNU General Public License as published by the |
| 8 | # Free Software Foundation; either version 2, or (at your option) any later |
8 | # Free Software Foundation; either version 2, or (at your option) any later |
| 9 | # version, or (b) the "Artistic License" which comes with this package. |
9 | # version, or (b) the "Artistic License" which comes with this package. |
| … | |
… | |
| 54 | @names{keys %{$self->{paramcache}}} = (); |
54 | @names{keys %{$self->{paramcache}}} = (); |
| 55 | return keys %names; |
55 | return keys %names; |
| 56 | } elsif (@_ == 1) { |
56 | } elsif (@_ == 1) { |
| 57 | my $name = shift; |
57 | my $name = shift; |
| 58 | if (exists $self->{paramcache}{$name}) { |
58 | if (exists $self->{paramcache}{$name}) { |
| 59 | my $val = $self->{paramcache}{$name}; |
59 | return wantarray ? @{$self->{paramcache}{$name}} : $self->{paramcache}{$name}->[0]; |
| 60 | if (ref $val eq "ARRAY") { |
|
|
| 61 | return @$val; |
|
|
| 62 | } else { |
|
|
| 63 | return $val; |
|
|
| 64 | } |
|
|
| 65 | } else { |
60 | } else { |
| 66 | return $self->SUPER::param($name); |
61 | return $self->SUPER::param($name); |
| 67 | } |
62 | } |
| 68 | } elsif (@_ == 2) { |
63 | } elsif (@_ == 2) { |
| 69 | my ($name, $val) = @_; |
64 | my ($name, $val) = @_; |
| 70 | $self->{paramcache}{$name} = $val; |
|
|
| 71 | if (ref $val eq "ARRAY") { |
65 | if (ref $val eq "ARRAY") { |
| 72 | return @$val; |
66 | $self->{paramcache}{$name} = $val; |
| 73 | } else { |
67 | } else { |
| 74 | return $val; |
68 | $self->{paramcache}{$name} = [$val]; |
| 75 | } |
69 | } |
|
|
70 | return wantarray ? @{$self->{paramcache}{$name}} : $self->{paramcache}{$name}->[0]; |
| 76 | } |
71 | } |
| 77 | } |
72 | }; |
| 78 | } |
73 | } |
| 79 | } |
74 | } |
| 80 | |
|
|
| 81 | |
75 | |
| 82 | =head1 CONSTRUCTOR |
76 | =head1 CONSTRUCTOR |
| 83 | |
77 | |
| 84 | =over |
78 | =over |
| 85 | |
79 | |