Catalyst::Plugin::Moostash - Provides Moose interface for stash
version v0.1.0
Define your Moostash class:
package MyApp::Moostash; use Moose; extends 'Catalyst::Plugin::Moostash::Base'; has user_id => ( is => 'ro', isa => 'Int', writer => 'set_user_id', );
Load plugin in MyApp class:
use Catalyst qw/ ConfigLoader Static::Simple ... Moostash /;
Then use it in your application:
sub some_action : Local { my ($self, $c) = @_; $c->moostash->set_user_id($user_id); }
Since the Moostash object is stored in the stash, you can conveniently access it from your View:
[% m.user_id %]
Also, note that Moostash object receives Catalyst context object into the ctx attribute.
ctx
__PACKAGE__->config( 'Plugin::Moostash' => { stash_key => 'm', class => 'MyApp::Moostash', }, );
Defines which stash key to use for storing Moostash object.
Default: m
m
Defines Moostash class name.
Default: MyApp::Moostash
MyApp::Moostash
Roman F. <romanf@cpan.org>
This software is copyright (c) 2012 by Roman F..
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Catalyst::Plugin::Moostash, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Plugin::Moostash
CPAN shell
perl -MCPAN -e shell install Catalyst::Plugin::Moostash
For more information on module installation, please visit the detailed CPAN module installation guide.