From: Shawn M Moore Date: Sun, 18 Jan 2009 02:55:12 +0000 (+0000) Subject: Document this new default X-Git-Tag: 0.05~14 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fa2e6c00d63c8797ee17240719ee6b713ad83a82;p=gitmo%2FMooseX-Role-Parameterized.git Document this new default --- diff --git a/lib/MooseX/Role/Parameterized.pm b/lib/MooseX/Role/Parameterized.pm index 83e88ed..1d2af1d 100644 --- a/lib/MooseX/Role/Parameterized.pm +++ b/lib/MooseX/Role/Parameterized.pm @@ -191,7 +191,6 @@ MooseX::Role::Parameterized - parameterized roles use MooseX::Role::Parameterized; parameter name => ( - is => 'ro', isa => 'Str', required => 1, ); @@ -234,8 +233,9 @@ Your parameterized role consists of two things: parameter declarations and a C block. Parameters are declared using the L keyword which very much -resembles L. You can use any option that L accepts. -These parameters will get their values when the consuming class (or role) uses +resembles L. You can use any option that L accepts. The +default value for the "is" option is "ro" as that's a very common case. These +parameters will get their values when the consuming class (or role) uses L. A parameter object will be constructed with these values, and passed to the C block. diff --git a/lib/MooseX/Role/Parameterized/Tutorial.pm b/lib/MooseX/Role/Parameterized/Tutorial.pm index 1163a49..5aba03b 100644 --- a/lib/MooseX/Role/Parameterized/Tutorial.pm +++ b/lib/MooseX/Role/Parameterized/Tutorial.pm @@ -47,15 +47,14 @@ exactly like specifying the attributes of a class. Instead of C you use the keyword C, but your parameters can use any options to C. parameter 'delegation' => ( - is => 'ro', isa => 'HashRef|ArrayRef|RegexpRef', predicate => 'has_delegation', ); Behind the scenes, C uses C to add attributes to a parameter -class. The arguments to C are used to construct a parameter object, which -has the attributes specified by calls to C. The parameter object is -then passed to... +class (except the "is" option defaults to "ro" for convenience). The arguments +to C are used to construct a parameter object, which has the attributes +specified by calls to C. The parameter object is then passed to... =head3 C @@ -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, 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, L, L. Which backend to use can be a parameter. parameter format => ( - is => 'ro', - isa => (enum ['Storable', 'YAML', 'JSON']), + isa => (enum ['Storable', 'YAML', 'JSON']), default => 'Storable', );