1Moose::Role(3)        User Contributed Perl Documentation       Moose::Role(3)
2
3
4

NAME

6       Moose::Role - The Moose Role
7

SYNOPSIS

9         package Eq;
10         use Moose::Role; # automatically turns on strict and warnings
11
12         requires 'equal';
13
14         sub no_equal {
15             my ($self, $other) = @_;
16             !$self->equal($other);
17         }
18
19         # ... then in your classes
20
21         package Currency;
22         use Moose; # automatically turns on strict and warnings
23
24         with 'Eq';
25
26         sub equal {
27             my ($self, $other) = @_;
28             $self->as_float == $other->as_float;
29         }
30

DESCRIPTION

32       Role support in Moose is pretty solid at this point. However, the best
33       documentation is still the the test suite. It is fairly safe to assume
34       Perl 6 style behavior and then either refer to the test suite, or ask
35       questions on #moose if something doesn't quite do what you expect.
36
37       We are planning writing some more documentation in the near future, but
38       nothing is ready yet, sorry.
39

EXPORTED FUNCTIONS

41       Moose::Role currently supports all of the functions that Moose exports,
42       but differs slightly in how some items are handled (see CAVEATS below
43       for details).
44
45       Moose::Role also offers two role-specific keyword exports:
46
47       requires (@method_names)
48           Roles can require that certain methods are implemented by any class
49           which "does" the role.
50
51       excludes (@role_names)
52           Roles can "exclude" other roles, in effect saying "I can never be
53           combined with these @role_names". This is a feature which should
54           not be used lightly.
55

CAVEATS

57       Role support has only a few caveats:
58
59       ·   Roles cannot use the "extends" keyword; it will throw an exception
60           for now.  The same is true of the "augment" and "inner" keywords
61           (not sure those really make sense for roles). All other Moose key‐
62           words will be deferred so that they can be applied to the consuming
63           class.
64
65       ·   Role composition does its best to not be order-sensitive when it
66           comes to conflict resolution and requirements detection. However,
67           it is order-sensitive when it comes to method modifiers. All
68           before/around/after modifiers are included whenever a role is com‐
69           posed into a class, and then applied in the order in which the
70           roles are used. This also means that there is no conflict for
71           before/around/after modifiers.
72
73           In most cases, this will be a non-issue; however, it is something
74           to keep in mind when using method modifiers in a role. You should
75           never assume any ordering.
76
77       ·   The "requires" keyword currently only works with actual methods. A
78           method modifier (before/around/after and override) will not count
79           as a fufillment of the requirement, and neither will an autogener‐
80           ated accessor for an attribute.
81
82           It is likely that attribute accessors will eventually be allowed to
83           fufill those requirements, or we will introduce a "requires_attr"
84           keyword of some kind instead. This decision has not yet been final‐
85           ized.
86

BUGS

88       All complex software has bugs lurking in it, and this module is no
89       exception. If you find a bug please either email me, or add the bug to
90       cpan-RT.
91

AUTHOR

93       Stevan Little <stevan@iinteractive.com>
94
95       Christian Hansen <chansen@cpan.org>
96
98       Copyright 2006, 2007 by Infinity Interactive, Inc.
99
100       <http://www.iinteractive.com>
101
102       This library is free software; you can redistribute it and/or modify it
103       under the same terms as Perl itself.
104
105
106
107perl v5.8.8                       2007-09-06                    Moose::Role(3)
Impressum