File: README

package info (click to toggle)
libmoosex-traits-pluggable-perl 0.10-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 204 kB
  • sloc: perl: 2,102; makefile: 2
file content (119 lines) | stat: -rw-r--r-- 3,284 bytes parent folder | download | duplicates (2)
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
114
115
116
117
118
119
NAME
    MooseX::Traits::Pluggable - trait loading and resolution for Moose

DESCRIPTION
    See MooseX::Traits for usage information.

    Use "new_with_traits" to construct an object with a list of traits and
    "apply_traits" to apply traits to an instance.

    Adds support for class precedence search for traits and some extra
    attributes, described below.

TRAIT SEARCH
    If the value of "_trait_namespace" in MooseX::Traits starts with a "+"
    the namespace will be considered relative to the "class_precedence_list"
    (ie. @ISA) of the original class.

    Example:

      package Class1
      use Moose;

      package Class1::Trait::Foo;
      use Moose::Role;
      has 'bar' => (
          is       => 'ro',
          isa      => 'Str',
          required => 1,
      );

      package Class2;
      use parent 'Class1';
      with 'MooseX::Traits';
      has '+_trait_namespace' => (default => '+Trait');

      package Class2::Trait::Bar;
      use Moose::Role;
      has 'baz' => (
          is       => 'ro',
          isa      => 'Str',
          required => 1,
      );

      package main;
      my $instance = Class2->new_with_traits(
          traits => ['Foo', 'Bar'],
          bar => 'baz',
          baz => 'quux',
      );

      $instance->does('Class1::Trait::Foo'); # true
      $instance->does('Class2::Trait::Bar'); # true

NAMESPACE ARRAYS
    You can search multiple namespaces for traits, for example:

      has '+_trait_namespace' => (
          default => sub { [qw/+Trait +Role ExtraNS::Trait/] }
      );

    Will search in the "class_precedence_list" for "::Trait::TheTrait" and
    "::Role::TheTrait" and then for "ExtraNS::Trait::TheTrait".

EXTRA ATTRIBUTES
  _original_class_name
    When traits are applied to your class or instance, you get an anonymous
    class back whose name will be not the same as your original class. So
    "ref $self" will not be "Class", but "$self->_original_class_name" will
    be.

  _traits
    List of the (unresolved) traits applied to the instance.

  _resolved_traits
    List of traits applied to the instance resolved to full package names.

SEE ALSO
    MooseX::Traits, MooseX::Object::Pluggable

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

SUPPORT
    More information at:

    *   RT: CPAN's request tracker

        <http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-Traits-Pluggable>

    *   AnnoCPAN: Annotated CPAN documentation

        <http://annocpan.org/dist/MooseX-Traits-Pluggable>

    *   CPAN Ratings

        <http://cpanratings.perl.org/d/MooseX-Traits-Pluggable>

    *   Search CPAN

        <http://search.cpan.org/dist/MooseX-Traits-Pluggable/>

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

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

COPYRIGHT & LICENSE
    Copyright (c) 2009 - 2010 by the aforementioned "AUTHOR" and
    "CONTRIBUTORS".

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