How to access the real App in prepare_arguments in Catalyst::Model::Adaptor
I've got a catalyst specific model class that I'd like to instanciate by wrapping it with the help of a Catalyst::Model::Adaptor
package MyClass;
use Moose;
has 'c' => ( is => 'ro' , isa => 'Catalyst' );
1;
package MyAPP::Model::MyClass
use base 'Catalyst::Model::Adaptor';
sub prepare_arguments {
my ($self, $app) = @开发者_运维知识库_; # $app sometimes written as $c
return { c => $app };
}
1;
The problem is that here $app is not an instance of MyAPP, but just the class name 'MyApp' .
How do I access the instance of MyApp from this method?
It's impossible. If you need an instance of the app, you need to build the model per request. Catalyst::Model::Factory::PerRequest will help!
精彩评论