Context - request-local storage
$ctx = Pinwheel::Context::get(); $ctx = Pinwheel::Context::get('template'); Pinwheel::Context::set(x => 'foo', y => 'bar', z => 42); Pinwheel::Context::set('template', foo => 'bar', baz => 'bal'); Pinwheel::Context::reset();
This module provides storage that can be completely emptied with a call to reset(). It is used by Controller to provide request-local storage for modules, and as the mechanism for sharing data between controllers and views.
reset()
Contexts are hashes (get returns a reference to a hash). Multiple contexts are supported by use of the optional NAMESPACE argument. Whenever NAMESPACE is omitted, it defaults to a value generated from the caller's package.
get
get()
get(NAMESPACE)
Retrieves a context hash.
Examples:
my $ctx = Pinwheel::Context::get(); return $ctx->{action};
or
my $ctx = Pinwheel::Context::get('template'); return $ctx->{pagetitle};
set(VALUES)
set(NAMESPACE, VALUES)
Set one or more values in the context. The appropriate context is emptied, then filled with the given VALUES.
Pinwheel::Context::set(x => 1, y => 42);
Pinwheel::Context::set('template', date => $date, message => $msg); Pinwheel::Context::set('template', schedule => $schedule); # 'date' and 'message' are now gone
Clears all the context information in all namespaces.
A&M Network Publishing <DLAMNetPub@bbc.co.uk>
To install Pinwheel, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Pinwheel
CPAN shell
perl -MCPAN -e shell install Pinwheel
For more information on module installation, please visit the detailed CPAN module installation guide.