NAME
Catalyst::Plugin::Moostash - Provides Moose interface for stash
VERSION
version v0.1.2
DESCRIPTION
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.
CONFIGURATION
__PACKAGE__->config(
'Plugin::Moostash' => {
stash_key => 'm',
class => 'MyApp::Moostash',
},
);
stash_key
Defines which stash key to use for storing Moostash object.
Default: m
class
Defines Moostash class name.
Default: MyApp::Moostash
AUTHOR
Roman F. <romanf@cpan.org>
COPYRIGHT AND LICENSE
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.