1MooseX::Traits::PluggabUlsee(r3)Contributed Perl DocumenMtoaotsieoXn::Traits::Pluggable(3)
2
3
4

NAME

6       MooseX::Traits::Pluggable - trait loading and resolution for Moose
7

DESCRIPTION

9       See MooseX::Traits for usage information.
10
11       Use "new_with_traits" to construct an object with a list of traits and
12       "apply_traits" to apply traits to an instance.
13
14       Adds support for class precedence search for traits and some extra
15       attributes, described below.
16
18       If the value of "_trait_namespace" in MooseX::Traits starts with a "+"
19       the namespace will be considered relative to the
20       "class_precedence_list" (ie.  @ISA) of the original class.
21
22       Example:
23
24         package Class1
25         use Moose;
26
27         package Class1::Trait::Foo;
28         use Moose::Role;
29         has 'bar' => (
30             is       => 'ro',
31             isa      => 'Str',
32             required => 1,
33         );
34
35         package Class2;
36         use parent 'Class1';
37         with 'MooseX::Traits';
38         has '+_trait_namespace' => (default => '+Trait');
39
40         package Class2::Trait::Bar;
41         use Moose::Role;
42         has 'baz' => (
43             is       => 'ro',
44             isa      => 'Str',
45             required => 1,
46         );
47
48         package main;
49         my $instance = Class2->new_with_traits(
50             traits => ['Foo', 'Bar'],
51             bar => 'baz',
52             baz => 'quux',
53         );
54
55         $instance->does('Class1::Trait::Foo'); # true
56         $instance->does('Class2::Trait::Bar'); # true
57

NAMESPACE ARRAYS

59       You can search multiple namespaces for traits, for example:
60
61         has '+_trait_namespace' => (
62             default => sub { [qw/+Trait +Role ExtraNS::Trait/] }
63         );
64
65       Will search in the "class_precedence_list" for "::Trait::TheTrait" and
66       "::Role::TheTrait" and then for "ExtraNS::Trait::TheTrait".
67

EXTRA ATTRIBUTES

69   _original_class_name
70       When traits are applied to your class or instance, you get an anonymous
71       class back whose name will be not the same as your original class. So
72       "ref $self" will not be "Class", but "$self->_original_class_name" will
73       be.
74
75   _traits
76       List of the (unresolved) traits applied to the instance.
77
78   _resolved_traits
79       List of traits applied to the instance resolved to full package names.
80

SEE ALSO

82       MooseX::Traits, MooseX::Object::Pluggable
83

BUGS

85       Please report any bugs or feature requests to
86       "bug-moosex-traits-pluggable at rt.cpan.org", or through the web
87       interface at
88       http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooseX-Traits-Pluggable
89       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooseX-Traits-
90       Pluggable>.  I will be notified, and then you'll automatically be
91       notified of progress on your bug as I make changes.
92

SUPPORT

94       More information at:
95
96       ·   RT: CPAN's request tracker
97
98           http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-Traits-Pluggable
99           <http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-Traits-Pluggable>
100
101       ·   AnnoCPAN: Annotated CPAN documentation
102
103           http://annocpan.org/dist/MooseX-Traits-Pluggable
104           <http://annocpan.org/dist/MooseX-Traits-Pluggable>
105
106       ·   CPAN Ratings
107
108           http://cpanratings.perl.org/d/MooseX-Traits-Pluggable
109           <http://cpanratings.perl.org/d/MooseX-Traits-Pluggable>
110
111       ·   Search CPAN
112
113           http://search.cpan.org/dist/MooseX-Traits-Pluggable/
114           <http://search.cpan.org/dist/MooseX-Traits-Pluggable/>
115

AUTHOR

117       Rafael Kitover "<rkitover@cpan.org>"
118

CONTRIBUTORS

120       Tomas Doran, "<bobtfish@bobtfish.net>"
121
123       Copyright (c) 2009 - 2010 by the aforementioned "AUTHOR" in
124       DBIx::Class::Schema::Loader and "CONTRIBUTORS" in
125       DBIx::Class::Schema::Loader.
126
127       This library is free software; you can redistribute it and/or modify it
128       under the same terms as Perl itself.
129
130
131
132perl v5.12.0                      2010-02-07      MooseX::Traits::Pluggable(3)
Impressum