CGI::Application::Plugin::Stash - add stash to CGI::Application


CGI-Application-Plugin-Stash documentation Contained in the CGI-Application-Plugin-Stash distribution.

Index


Code Index:

NAME

Top

CGI::Application::Plugin::Stash - add stash to CGI::Application

SYNOPSIS

Top

  use CGI::Application::Plugin::Stash;

  $self->stash->{foo}='bar';

  $self->param('foo','bar'); #same




DESCRIPTION

Top

CGI::Application::Plugin::Stash is a plugin for CGI::Application. This module allow you to call stash like Catalyst.

SEE ALSO

Top

CGI::Application

Catalyst

AUTHOR

Top

Masahiro Nagano, <kazeburo@gmail.com>

COPYRIGHT AND LICENSE

Top


CGI-Application-Plugin-Stash documentation Contained in the CGI-Application-Plugin-Stash distribution.

package CGI::Application::Plugin::Stash;

use strict;
use warnings;
use vars qw($VERSION @EXPORT);
require Exporter;

@EXPORT = qw(stash);
$VERSION = '0.01';

sub import { goto &Exporter::import }

sub stash{
    my $self = shift;
    
    # First use?  Create new __PARAMS!
    $self->{__PARAMS} = {} unless (exists($self->{__PARAMS}));
    
    # This code stolen from Catalyst::Engine
    if (@_) {
        my $stash = @_ > 1 ? {@_} : $_[0];
        while ( my ( $key, $val ) = each %$stash ) {
            $self->{__PARAMS}->{$key} = $val;
        }
    }
    
    return $self->{__PARAMS};
}

1;


__END__