NAME
Catalyst::Plugin::CurrentComponents - Declare current components more easily.
SYNOPSIS
Use the plugin in your application class:
package MyApp;
use Catalyst 'CurrentComponents';
MyApp->setup;
Then you can use it in your controllers:
package MyApp::Controller::Example;
use base 'Catalyst::Controller';
sub current_model_instance {
my ($self, $c) = @_;
return $c->model("Form::Login", user_database => $c->model('Users'));
}
sub myaction :Local {
my ($self, $c) = @_;
my $c->model; # Isa 'MyApp::Model::Form::Login', or whatever that returns;
}
DESCRIPTION
This plugin gives you an alternative to setting the current_view|model(_instance) via a controller method or via context helper methods. You may find this a more readable approach than setting it via the stash.
Please Seee documention about Views and Models in Catalyst.
METHODS
This plugin adds the following methods to your context.
current_model
Sets $c->stash->{current_model} if an argument is passed. Always returns the current value of this stash key
current_model_instance
Sets $c->stash->{current_model_instance} if an argument is passed. Always returns the current value of this stash key
current_view
Sets $c->stash->{current_view} if an argument is passed. Always returns the current value of this stash key
current_view_instance
Sets $c->stash->{current_view_instance} if an argument is passed. Always returns the current value of this stash key
AUTHOR
John Napiorkowski email:jjnapiork@cpan.org
SEE ALSO
COPYRIGHT & LICENSE
Copyright 2015, John Napiorkowski email:jjnapiork@cpan.org
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.