Document this new default
[gitmo/MooseX-Role-Parameterized.git] / lib / MooseX / Role / Parameterized / Tutorial.pm
index af18902..5aba03b 100644 (file)
@@ -20,10 +20,10 @@ you don't want or need (see L<Moose::Cookbook::Roles::Recipe2> for more
 about C<alias> and C<excludes>).
 
 Because roles serve many different masters, they usually provide only the least
-common denominator of functionality. Not all consumers of a role have a C<>.
-Thus, more configurability than C<alias> and C<excludes> is required. Perhaps
-your role needs to know which method to call when it is done. Or what default
-value to use for its url attribute.
+common denominator of functionality. To empower roles further, more
+configurability than C<alias> and C<excludes> is required. Perhaps your role
+needs to know which method to call when it is done. Or what default value to
+use for its url attribute.
 
 Parameterized roles offer exactly this solution.
 
@@ -47,22 +47,21 @@ exactly like specifying the attributes of a class. Instead of C<has> you use
 the keyword C<parameter>, but your parameters can use any options to C<has>.
 
     parameter 'delegation' => (
-        is        => 'ro',
         isa       => 'HashRef|ArrayRef|RegexpRef',
         predicate => 'has_delegation',
     );
 
 Behind the scenes, C<parameter> uses C<has> to add attributes to a parameter
-class. The arguments to C<with> are used to construct a parameter object, which
-has the attributes specified by calls to C<parameter>. The parameter object is
-then passed to...
+class (except the "is" option defaults to "ro" for convenience). The arguments
+to C<with> are used to construct a parameter object, which has the attributes
+specified by calls to C<parameter>. The parameter object is then passed to...
 
 =head3 C<role>
 
 C<role> takes a block of code that will be used to generate your role with its
-parameters bound. Here is where you put your regular role code: use C<has>,
-method modifiers, and so on. You receive as an argument the parameter object
-constructed by C<with>. You can access the parameters just like regular
+parameters bound. Here is where you declare parameterized components: use
+C<has>, method modifiers, and so on. You receive as an argument the parameter
+object constructed by C<with>. You can access the parameters just like regular
 attributes on that object (assuming you declared them readable).
 
 Each time you compose this parameterized role, the role {} block will be
@@ -70,9 +69,9 @@ executed. It will receive a new parameter object and produce an entirely new
 role.
 
 Due to limitations inherent in Perl, you must declare methods with
-C<method name => sub { ... }> instead of the usual C<sub name { ... }>. Your
-methods may, of course, close over the parameter object. This means that your
-methods may use parameters however they wish!
+C<< method name => sub { ... } >> instead of the usual C<sub name { ... }>.
+Your methods may, of course, close over the parameter object. This means that
+your methods may use parameters however they wish!
 
 =head1 IMPLEMENTATION NOTES
 
@@ -89,7 +88,6 @@ You can rename methods with core Moose, but now you can rename attributes. You
 can now also choose type, default value, whether it's required, B<traits>, etc.
 
     parameter traits => (
-        is      => 'ro',
         isa     => 'ArrayRef[Str]',
         default => sub { [] },
     );
@@ -106,7 +104,6 @@ require that you specify a method name you wish the role to instrument, or
 which attributes to dump to a file.
 
     parameter instrument_method => (
-        is       => 'ro',
         isa      => 'Str',
         required => 1,
     );
@@ -120,7 +117,6 @@ operate. For example, you can tell the role whether to save intermediate
 states.
 
     parameter save_intermediate => (
-        is      => 'ro',
         isa     => 'Bool',
         default => 0,
     );
@@ -137,8 +133,7 @@ Your role may be able to freeze and thaw your instances using L<YAML>, L<JSON>,
 L<Storable>. Which backend to use can be a parameter.
 
     parameter format => (
-        is => 'ro',
-        isa => (enum ['Storable', 'YAML', 'JSON']),
+        isa     => (enum ['Storable', 'YAML', 'JSON']),
         default => 'Storable',
     );