From: rodrigolive Date: Wed, 2 Sep 2009 23:22:26 +0000 (+0200) Subject: Documenting that 'has' comes before 'with' when satisfying role requirements X-Git-Tag: 0.89_02~49 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4ec0c7fe043112bba9fe16a2432bb3c6faf0e980;p=gitmo%2FMoose.git Documenting that 'has' comes before 'with' when satisfying role requirements --- diff --git a/lib/Moose/Manual/Roles.pod b/lib/Moose/Manual/Roles.pod index 938f348..45265e4 100644 --- a/lib/Moose/Manual/Roles.pod +++ b/lib/Moose/Manual/Roles.pod @@ -28,7 +28,7 @@ methods, in which case the role would be very much like a Java interface. Note that attribute accessors also count as methods for the -purposes of satisfying the requirements of a role. +purposes of satisfying the requirements of a role. =head1 A SIMPLE ROLE @@ -169,6 +169,30 @@ class to the mix would not achieve anything. We recommend that you simply consume the interface role in each class which implements that interface. +=head2 Required Attributes + +As mentioned before, a role requirement may also be satisfied by an +attribute accessor. But any C functions, which will generate +accessors that satisfy the role requirement, must be placed +I the C function that composes the role. + + package Breakable; + + use Moose::Role; + + requires 'stress'; + + package Car; + + use Moose; + + has 'stress' => ( + is => 'rw', + isa => 'Int', + ); + + with 'Breakable'; + =head1 USING METHOD MODIFIERS Method modifiers and roles are a very powerful combination. Often, a