add POD to PseudoRequest. Also, refactor initializing the cached print values
This commit is contained in:
parent
3f0656e971
commit
f555408b95
1 changed files with 29 additions and 4 deletions
|
|
@ -109,6 +109,7 @@ sub new {
|
||||||
fh => undef,
|
fh => undef,
|
||||||
size => 0,
|
size => 0,
|
||||||
filename => '',
|
filename => '',
|
||||||
|
output => '',
|
||||||
};
|
};
|
||||||
my $file = shift;
|
my $file = shift;
|
||||||
if ($file and -e $file) {
|
if ($file and -e $file) {
|
||||||
|
|
@ -349,22 +350,46 @@ sub setup_param {
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 clear_output ( )
|
||||||
|
|
||||||
|
Clear the internally cached request output generated by calling the
|
||||||
|
C<print> method.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
sub clear_output {
|
sub clear_output {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->{output} = '';
|
$self->{output} = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 get_output ( )
|
||||||
|
|
||||||
|
Get the internally cached request output generated by calling the
|
||||||
|
C<print> method. Returns it as a scalar.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
sub get_output {
|
sub get_output {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return $self->{output};
|
return $self->{output};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 print ( @values )
|
||||||
|
|
||||||
|
Fake print method for the PseudoRequest object. It caches everything printed
|
||||||
|
to it by concatenating @values together, just like print would. Use clear_output
|
||||||
|
to clear the cached value, and get_output to access it.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
sub print {
|
sub print {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->{output} ||= '';
|
$self->{output} .= join '', @_;
|
||||||
for my $p (@_) {
|
return 1;
|
||||||
$self->{output} .= $p;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue