X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FRole.pm;h=25926ad58de8a184c4f16d6e359a3b582438da9c;hb=66e3df7a8d3d839b53f6fc3af8f4bad6fc27fefe;hp=fe42f6f11d6537ff3b972eb67540a67b6a13e5c4;hpb=6a7756cc831fa21bc28b924a8edbaeeb28a4a66b;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Role.pm b/lib/Mouse/Role.pm index fe42f6f..25926ad 100644 --- a/lib/Mouse/Role.pm +++ b/lib/Mouse/Role.pm @@ -1,7 +1,7 @@ package Mouse::Role; use Mouse::Exporter; # enables strict and warnings -our $VERSION = '0.78'; +our $VERSION = '0.88'; use Carp qw(confess); use Scalar::Util qw(blessed); @@ -137,7 +137,7 @@ Mouse::Role - The Mouse Role =head1 VERSION -This document describes Mouse version 0.78 +This document describes Mouse version 0.88 =head1 SYNOPSIS @@ -166,67 +166,81 @@ This document describes Mouse version 0.78 my $bar = MyObject->new(); $obj->equals($bar); # yes, it is comparable -=head1 KEYWORDS +=head1 DESCRIPTION -=head2 C<< meta -> Mouse::Meta::Role >> +This module declares the caller class to be a Mouse role. -Returns this role's metaclass instance. +The concept of roles is documented in L. +This document serves as API documentation. -=head2 C<< before (method|methods|regexp) -> CodeRef >> +=head1 EXPORTED FUNCTIONS -Sets up a B method modifier. See L. +Mouse::Role supports all of the functions that Mouse exports, but +differs slightly in how some items are handled (see L below +for details). -=head2 C<< after (method|methods|regexp) => CodeRef >> +Mouse::Role also offers two role-specific keywords: -Sets up an B method modifier. See L. +=head2 C<< requires(@method_names) >> -=head2 C<< around (method|methods|regexp) => CodeRef >> +Roles can require that certain methods are implemented by any class which +C the role. -Sets up an B method modifier. See L. +Note that attribute accessors also count as methods for the purposes of +satisfying the requirements of a role. -=head2 C +=head2 C<< excludes(@role_names) >> -Sets up the B keyword. See L. +This is exported but not implemented in Mouse. -=head2 C<< override method => CodeRef >> +=head1 IMPORT AND UNIMPORT -Sets up an B method modifier. See L. +=head2 import -=head2 C +Importing Mouse::Role will give you sugar. C<-traits> are also supported. -This is not supported in roles and emits an error. See L. +=head2 unimport -=head2 C<< augment method => CodeRef >> +Please unimport (C<< no Mouse::Role >>) so that if someone calls one of the +keywords (such as L) it will break loudly instead breaking subtly. -This is not supported in roles and emits an error. See L. +=head1 CAVEATS -=head2 C<< has (name|names) => parameters >> +Role support has only a few caveats: -Sets up an attribute (or if passed an arrayref of names, multiple attributes) to -this role. See L. +=over -=head2 C<< confess(error) -> BOOM >> +=item * -L for your convenience. +Roles cannot use the C keyword; it will throw an exception for now. +The same is true of the C and C keywords (not sure those +really make sense for roles). All other Mouse keywords will be I +so that they can be applied to the consuming class. -=head2 C<< blessed(value) -> ClassName | undef >> +=item * -L for your convenience. +Role composition does its best to B be order-sensitive when it comes to +conflict resolution and requirements detection. However, it is order-sensitive +when it comes to method modifiers. All before/around/after modifiers are +included whenever a role is composed into a class, and then applied in the order +in which the roles are used. This also means that there is no conflict for +before/around/after modifiers. -=head1 MISC +In most cases, this will be a non-issue; however, it is something to keep in +mind when using method modifiers in a role. You should never assume any +ordering. -=head2 import +=back -Importing Mouse::Role will give you sugar. +=head1 SEE ALSO -=head2 unimport +L -Please unimport (C<< no Mouse::Role >>) so that if someone calls one of the -keywords (such as L) it will break loudly instead breaking subtly. +L -=head1 SEE ALSO +L -L +L =cut