WWW::Pipeline::Services::RunModes
This plugin is an implementation of the Run Mode paradigm as seen in Jesse Erlbaum's CGI::Application module.
The quick summary of the Run Mode concept is that a web application will typically need one function for each screen of output. Which screen to produce is determined by the data in the request received. Rather than writing a very large set of if/else statements or a switch statement, the Run Mode concept uses a hash table of named callbacks to represent the possible responses, and a decision mechanism generates the key to the hash which determines which run mode is run. The decision mechanism may be as simple as a CGI parameter, or as complex as parsing different parts of the request, paired with authorization data.
One thing that this plugin does not replicate, however, is the run mode decision mechanism. Deciding which run mode to use can be done in many ways, and would best be done by a handler (or two - in the case where the run mode may be changed according to user authorization) installed during the ParseRequest phase of the Pipeline.
Services
run_modes
#set:
$self->run_modes(
one => \&doSomething,
two => 'doSomethingElse'
);
#retrieve
my $method = $self->run_modes('one');
#reassign:
$self->run_modes('one' => \&someOtherMethod );
#delete:
$self->run_modes( two => undef );
This service stores and manipulates a list of run modes to be used by the plugin's GenerateResponse handler. Run Modes may either be specified by name or by subroutine reference. Specifying by name makes way for inheritence, while
mode
#set
$self->mode('one');
#retrieve
$self->mode();
This service stores the decision made by the application as to which run mode is to be run during the GenerateResponse phase.
Handlers
executeRunMode
this handler, installed during the GenerateResponse phase, takes the information provided to the run_modes
and mode
services and determines what method to execute. It then runs that run mode, capturing its output. It expects that the output the method returns is the content it wants to return to the user, and stores it via the application's response
service for later retrieval.
Authors
Stephen Howard <stephen@thunkit.com>
License
This module may be distributed under the same terms as Perl itself.