File: README

package info (click to toggle)
libcatalystx-component-traits-perl 0.19-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, jessie, jessie-kfreebsd, sid, stretch
  • size: 144 kB
  • ctags: 5
  • sloc: perl: 102; makefile: 2
file content (113 lines) | stat: -rw-r--r-- 3,171 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
NAME
    CatalystX::Component::Traits - Automatic Trait Loading and Resolution
    for Catalyst Components

SYNOPSIS
        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']
        });

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

TRAIT SEARCH
    Trait names qualified with a "+" are taken to be full package names.

    Unqualified names are searched for, using the algorithm described below.

  EXAMPLE
    Suppose your inheritance hierarchy is:

        MyApp::Model::MyModel
        Catalyst::Model::CatModel
        Catalyst::Model
        Catalyst::Component
        Moose::Object

    The configuration is:

        traits => ['Foo']

    The package search order for "Foo" will be:

        MyApp::TraitFor::Model::CatModel::Foo
        Catalyst::TraitFor::Model::CatModel::Foo

  A MORE PATHOLOGICAL EXAMPLE
    For:

        My::App::Controller::AController
        CatalystX::Something::ControllerBase::SomeController
        Catalyst::Controller
        Catalyst::Model
        Catalyst::Component
        Moose::Object

    With:

        traits => ['Foo']

    Search order for "Foo" will be:

        My::App::TraitFor::Controller::SomeController::Foo
        CatalystX::Something::TraitFor::Controller::SomeController::Foo

    The "Base" after (M|V|C) is automatically removed.

TRAIT MERGING
    Traits from component class config and app config are automatically
    merged if you set the "_trait_merge" attribute default, e.g.:

        has '+_trait_merge' => (default => 1);

    You can remove component class config traits by prefixing their names
    with a "-" in the app config traits.

    For example:

        package Catalyst::Model::Foo;
        has '+_trait_merge' => (default => 1);
        __PACKAGE__->config->{traits} = [qw/Foo Bar/];

        package MyApp;
        __PACKAGE__->config->{'Model::Foo'}{traits} = [qw/-Foo Baz/];

    Will load the traits:

        Bar Baz

AUTHOR
    Rafael Kitover, "<rkitover@cpan.org>"

CONTRIBUTORS
    Tomas Doran, "<bobtfish@bobtfish.net>"

BUGS
    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-Trai
    ts>. I will be notified, and then you'll automatically be notified of
    progress on your bug as I make changes.

ACKNOWLEDGEMENTS
    Matt S. Trout and Tomas Doran helped me with the current design.

COPYRIGHT & LICENSE
    Copyright (c) 2014, Rafael Kitover

    This program is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.