CatalystX::ComponentsFromConfig::Role::AdaptorRole - parameterised role for trait-aware component adaptors
version 1.006
Here we document implementation details, see CatalystX::ComponentsFromConfig::ModelAdaptor and CatalystX::ComponentsFromConfig::ViewAdaptor for usage examples.
This role uses MooseX::Traits::Pluggable to allow you to add roles to your model classes via the configuration.
class
The name of the class to adapt.
args
Hashref of arguments to pass to the constructor of the adapted class.
args_format
String indicating how to pass the constructor arguments to the adapted class. One of:
hashref
Pass the arguments as a hash reference.
list
Flatten the arugments into a key/value list.
traits
Arrayref of traits / roles to apply to the class we're adapting.
If set, and the "class" has a new_with_traits constructor, it will be called with "args" augmented by traits => $traits. If "class" does not have that constructor, a subclass will be created by applying MooseX::Traits::Pluggable to "class", to get the new_with_traits constructor.
new_with_traits
traits => $traits
If "class" provides new_with_traits, that constructor is expected to deal with converting whatever is in traits into actual module names. If, instead, we have to inject MooseX::Traits::Pluggable, we depend on its own name expansion, but we provide our own set of namspaces: given a "class" of My::App::Special::Class::For::Things loaded into the My::App Catalyst application, the following namespaces will be searched for traits / roles:
My::App::Special::Class::For::Things
My::App
My::App::TraitFor::Special::Class::For::Things
My::App::TraitFor::Class::For::Things
My::App::TraitFor::For::Things
My::App::TraitFor::Things
My::App::TraitFor::${component_type}::Things
On the other hand, if the class name does not start with the application name, just ${class}::TraitFor will be searched.
${class}::TraitFor
component_type
The type of component to create, in lower case. Usually one of 'model', 'view' or 'controller'. There is no pre-packaged adptor to create controllers, mostly because I could not think of a sensible way to write it.
'model'
'view'
'controller'
Tomas Doran (t0m) <bobtfish@bobtfish.net>
Gianni Ceccarelli <gianni.ceccarelli@net-a-porter.com>
This software is copyright (c) 2012 by Net-a-porter.com.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install CatalystX::ComponentsFromConfig, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CatalystX::ComponentsFromConfig
CPAN shell
perl -MCPAN -e shell install CatalystX::ComponentsFromConfig
For more information on module installation, please visit the detailed CPAN module installation guide.