finish rough POD docs for WebGUI::PseudoRequest

This commit is contained in:
Colin Kuskie 2008-02-02 00:16:42 +00:00
parent 0a17df8174
commit ebfc711f65

View file

@ -20,9 +20,9 @@ Package WebGUI::PseudoRequest
=head1 DESCRIPTION
This is the most complete imitation of Apache2::Request. You can use this package to
This is an almost complete imitation of Apache2::Request. You can use this package to
create a request object that will work with WebGUI, without actually being inside
the mod_perl environment?
the mod_perl environment.
Why in the world would you want to do this? Well, when doing API testing sometimes
you run across things that require a request object, but you don't really want to
@ -32,6 +32,19 @@ fire up Apache in order to do it. This will let you bypass that.
package WebGUI::PseudoRequest::Headers;
#----------------------------------------------------------------------------
=head1 NAME
Package WebGUI::PseudoRequest::Headers
=head2 new
Construct a new PseudoRequest::Headers object. This is just for holding headers.
It doesn't do any magic.
=cut
sub new {
my $this = shift;
my $class = ref($this) || $this;
@ -40,6 +53,14 @@ sub new {
return $self;
}
#----------------------------------------------------------------------------
=head2 set( $key, $value )
Set a key, value pair in the header object.
=cut
sub set {
my $self = shift;
my $key = shift;
@ -47,6 +68,14 @@ sub set {
$self->{headers}->{$key} = $value;
}
#----------------------------------------------------------------------------
=head2 fetch
Returns the entire internal hashref of headers.
=cut
sub fetch {
my $self = shift;
return $self->{headers};
@ -54,6 +83,25 @@ sub fetch {
package WebGUI::PseudoRequest::Upload;
#----------------------------------------------------------------------------
=head1 NAME
Package WebGUI::PseudoRequest::Upload
=head2 new ( [$file] )
Construct a new PseudoRequest::Upload object. This is just for holding headers.
It doesn't do any magic.
=head3 $file
The complete path to a file. If this is sent to new, it will go ahead and open
a filehandle to that file for you, saving you the need to call the fh, filename
and filesize methods.
=cut
sub new {
my $this = shift;
my $class = ref($this) || $this;
@ -74,6 +122,15 @@ sub new {
return $self;
}
#----------------------------------------------------------------------------
=head2 fh ( [$value] )
Getter and setter for fh. If $value is passed in, it will set the internal filehandle in
the object to that. Returns the filehandle stored in the object.
=cut
sub fh {
my $self = shift;
my $value = shift;
@ -83,6 +140,15 @@ sub fh {
return $self->{fh};
}
#----------------------------------------------------------------------------
=head2 filaname ( [$value] )
Getter and setter for filename. If $value is passed in, it will set the filename in
the object to that. Returns the filename in the object.
=cut
sub filename {
my $self = shift;
my $value = shift;
@ -92,6 +158,15 @@ sub filename {
return $self->{filename};
}
#----------------------------------------------------------------------------
=head2 size ( [$value] )
Getter and setter for size. If $value is passed in, it will set the internal size in
the object to that. Returns the size stored in the object.
=cut
sub size {
my $self = shift;
my $value = shift;
@ -105,6 +180,10 @@ package WebGUI::PseudoRequest;
#----------------------------------------------------------------------------
=head1 NAME
Package WebGUI::PseudoRequest
=head2 new
Construct a new PseudoRequest object. Creates a new Headers object as well and places
@ -121,6 +200,8 @@ sub new {
return $self;
}
#----------------------------------------------------------------------------
=head2 body ( [$value])
Compatibility method. Returns the requested form value, $value. If $value isn't passed in, returns
@ -154,6 +235,8 @@ sub body {
}
}
#----------------------------------------------------------------------------
=head2 setup_body ( $value )
Setup the object's body method so that it can be used. $value should be a hash ref of named
@ -167,6 +250,8 @@ sub setup_body {
$self->{body} = $value;
}
#----------------------------------------------------------------------------
=head2 content_type ( [$value] )
Getter and setter for content_type. If $value is passed in, it will set the content_type of
@ -183,6 +268,8 @@ sub content_type {
return $self->{content_type};
}
#----------------------------------------------------------------------------
=head2 headers_out ( )
Returns the PseudoRequst::Headers object stored in $self for access to the headers.
@ -194,6 +281,8 @@ sub headers_out {
return $self->{headers_out}; ##return object for method chaining
}
#----------------------------------------------------------------------------
=head2 no_cache ( [$value] )
Getter and setter for no_cache. If $value is passed in, it will set no_cache of
@ -210,6 +299,14 @@ sub no_cache {
return $self->{no_cache};
}
#----------------------------------------------------------------------------
=head2 param ( [$value])
Compatibility method. Works exactly like the body method.
=cut
sub param {
my $self = shift;
my $value = shift;
@ -235,12 +332,30 @@ sub param {
}
}
#----------------------------------------------------------------------------
=head2 setup_param ( $value )
Setup the object's param method so that it can be used. $value should be a hash ref of named
form variables and values.
=cut
sub setup_param {
my $self = shift;
my $value = shift;
$self->{param} = $value;
}
#----------------------------------------------------------------------------
=head2 protocol ( $value )
Getter and setter for protocol. If $value is passed in, it will set the protocol of
the object to that. Returns the protocol value stored in the object.
=cut
sub protocol {
my $self = shift;
my $value = shift;
@ -250,6 +365,15 @@ sub protocol {
return $self->{protocol};
}
#----------------------------------------------------------------------------
=head2 status ( $value )
Getter and setter for status. If $value is passed in, it will set the status of
the object to that. Returns the status value stored in the object.
=cut
sub status {
my $self = shift;
my $value = shift;
@ -259,6 +383,15 @@ sub status {
return $self->{status};
}
#----------------------------------------------------------------------------
=head2 status_line ( $value )
Getter and setter for status_line. If $value is passed in, it will set the status_line of
the object to that. Returns the status_line value stored in the object.
=cut
sub status_line {
my $self = shift;
my $value = shift;
@ -268,6 +401,21 @@ sub status_line {
return $self->{status_line};
}
#----------------------------------------------------------------------------
=head2 upload ( $formName, [ $uploadFileHandler ] )
Getter and setter for upload objects, which are indexed in this object by $formName.
Returns what was stored in the slot referred to as $formName. If $formName is false,
it returns undef.
=head3 $uploadFileHandle.
$uploadFileHandle should be an array ref of WebGUI::PseudoRequest::Upload objects. If you
pass it $uploadFileHandle, it will set store the object under the name, $formName.
=cut
sub upload {
my $self = shift;
my $formName = shift;
@ -279,6 +427,21 @@ sub upload {
return @{ $self->{uploads}->{$formName} };
}
#----------------------------------------------------------------------------
=head2 uploadFiles ( $formName, $filesToUpload )
Convenience method for uploading several files at once into the PseudoRequest object,
all to be referenced off of $formName. If $formName is false, it returns undef.
=head3 $fileToUpload
$uploadFileHandle should be an array ref of complete paths to files. The method will
create one PseudoRequest::Upload object per file, then store the array ref
using the upload method.
=cut
sub uploadFiles {
my $self = shift;
my $formName = shift;
@ -293,6 +456,15 @@ sub uploadFiles {
$self->upload($formName, \@uploadObjects);
}
#----------------------------------------------------------------------------
=head2 uri ( $value )
Getter and setter for uri. If $value is passed in, it will set the uri of
the object to that. Returns the uri value stored in the object.
=cut
sub uri {
my $self = shift;
my $value = shift;
@ -302,6 +474,15 @@ sub uri {
return $self->{uri};
}
#----------------------------------------------------------------------------
=head2 user ( $value )
Getter and setter for user. If $value is passed in, it will set the user of
the object to that. Returns the user value stored in the object.
=cut
sub user {
my $self = shift;
my $value = shift;