Catalyst::Model::Adaptor

Catalyst::Model::Adaptor is a Perl module to use a plain class as a Catalyst model.
Download

Catalyst::Model::Adaptor Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Jonathan Rockway
  • Publisher web site:
  • http://search.cpan.org/~jrockway/

Catalyst::Model::Adaptor Tags


Catalyst::Model::Adaptor Description

Catalyst::Model::Adaptor is a Perl module to use a plain class as a Catalyst model. Catalyst::Model::Adaptor is a Perl module to use a plain class as a Catalyst model.SYNOPSISGiven a good old perl class like: package NotMyApp::SomeClass; use Moose; # to provide "new" sub method { 'yay' }Wrap it with a Catalyst model: package MyApp::Model::SomeClass; use base 'Catalyst::Model::Adaptor'; __PACKAGE__->config( class => 'NotMyApp::SomeClass' );Then you can use NotMyApp::Class from your Catalyst app: sub action :Whatever { my ($self, $c) = @_; my $someclass = $c->model('SomeClass'); $someclass->method; # yay }Note that NotMyApp::Class is instantiated at application startup time. If you want the adapted class to be created for call to $c->model, see Catalyst::Model::Factory instead. If you want the adapted class to be created once per request, see Catalyst::Model::Factory::PerRequest.The idea is that you don't want your Catalyst model to be anything other than a line or two of glue. Using this module ensures that your Model classes are separate from your application and therefore are well-abstracted, reusable, and easily testable.Right now there are too many modules on CPAN that are Catalyst-specific. Most of the models would be better written as a class that handles most of the functionality with just a bit of glue to make it work nicely with Catalyst. This module aims to make integrating your class with Catalyst trivial, so you won't have to do any extra work to make your model generic.For a good example of a Model that takes the right design approach, take a look at Catalyst::Model::DBIC::Schema. All it does is glues an existing DBIx::Class::Schema to Catalyst. It provides a bit of sugar, but no actual functionality. Everything important happens in the DBIx::Class::Schema object.The end result of that is that you can use your app's DBIC schema without ever thinking about Catalyst. This is a Good Thing. Requirements: · Perl


Catalyst::Model::Adaptor Related Software