CatalystX::Component::Traits - Automatic Trait Loading and Resolution for Catalyst Components
Version 0.02
package Catalyst::Model::SomeModel; with 'CatalystX::Component::Traits'; package MyApp::Model::MyModel; use parent 'Catalyst::Model::SomeModel'; package MyApp; __PACKAGE__->config('Model::MyModel' => { traits => ['SearchedForTrait', '+Fully::Qualified::Trait'] });
Adds a "COMPONENT" in Catalyst::Component method to your Catalyst component base class that reads the optional traits parameter from app and component config and instantiates the component subclass with those traits using "new_with_traits" in MooseX::Traits from MooseX::Traits::Pluggable.
traits
Trait names qualified with a + are taken to be full package names.
+
Unqualified names are searched for, using the algorithm described below.
Suppose your inheritance hierarchy is:
MyApp::Model::MyModel MyAppBase::Model::BaseModel Catalyst::Model::CatModel Catalyst::Model Catalyst::Component Moose::Object
The configuration is:
traits => ['Foo']
The package search order for Foo will be:
Foo
MyApp::TraitFor::Model::CatModel::Foo, MyAppBase::TraitFor::Model::CatModel::Foo, Catalyst::TraitFor::Model::CatModel::Foo, Catalyst::TraitFor::Model::Foo, Catalyst::TraitFor::Component::Foo, MooseX::TraitFor::Object::Foo
Rafael Kitover, <rkitover at cpan.org>
<rkitover at cpan.org>
Please report any bugs or feature requests to bug-catalystx-component-traits at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CatalystX-Component-Traits. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-catalystx-component-traits at rt.cpan.org
More information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=CatalystX-Component-Traits
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/CatalystX-Component-Traits
CPAN Ratings
http://cpanratings.perl.org/d/CatalystX-Component-Traits
Search CPAN
http://search.cpan.org/dist/CatalystX-Component-Traits/
Matt S. Trout and Tomas Doran helped me with the current design.
Copyright (c) 2009, Rafael Kitover
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install CatalystX::Component::Traits, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CatalystX::Component::Traits
CPAN shell
perl -MCPAN -e shell install CatalystX::Component::Traits
For more information on module installation, please visit the detailed CPAN module installation guide.