Catalyst::TraitFor::Model::DBIC::Schema::Result - PerRequest Result from Catalyst Request
In your configuration, set the trait:
MyApp->config( 'Model::Schema' => { traits => ['Result'], schema_class => 'MyApp::Schema', connect_info => [ ... ], }, );
Now in your actions you can call the generated models, which get their ->find($id) from $c->request->args.
sub user :Local Args(1) { my ($self, $c) = @_; my $user = $c->model('Schema::User::Result'); }
Its a common case to get the result of a DBIx::Class ->find based on the current Catalyst request (typically from the Args attribute). This is an experimental trait to see if we can usefull encapsulate that common task in a way that is not easily broken.
If you can't read the source code and figure out what is going on, might want to stay away for now!
Catalyst, Catalyst::Model::DBIC::Schema.
John Napiorkowski email:jjnapiork@cpan.org
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.
To install Catalyst::TraitFor::Model::DBIC::Schema::Result, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::TraitFor::Model::DBIC::Schema::Result
CPAN shell
perl -MCPAN -e shell install Catalyst::TraitFor::Model::DBIC::Schema::Result
For more information on module installation, please visit the detailed CPAN module installation guide.