NAME

CatalystX::ComponentsFromConfig::Role::AdaptorRole - parameterised role for trait-aware component adaptors

VERSION

version 1.006

DESCRIPTION

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.

ATTRIBUTES

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 (default)

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.

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::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.

ROLE PARAMETERS

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.

AUTHORS

  • Tomas Doran (t0m) <bobtfish@bobtfish.net>

  • Gianni Ceccarelli <gianni.ceccarelli@net-a-porter.com>

COPYRIGHT AND LICENSE

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.