From: Stevan Little Date: Thu, 5 Apr 2007 19:55:00 +0000 (+0000) Subject: 0.19 release X-Git-Tag: 0_21~28 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cd7eeaf509af1339004a297e1f6fcbfb43fa4582;p=gitmo%2FMoose.git 0.19 release --- diff --git a/Changes b/Changes index 2eb8e43..2246443 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,8 @@ Revision history for Perl extension Moose -0.19 +0.19 Thurs. April 5th, 2007 + ~~ More documentation updates ~~ + * Moose::Util::TypeConstraints - 'type' now supports messages as well thanks to phaylon for finding this diff --git a/lib/Moose.pm b/lib/Moose.pm index 553c7e3..22ee850 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -364,7 +364,7 @@ superclasses still properly inherit from L. This will apply a given set of C<@roles> to the local class. Role support is currently under heavy development; see L for more details. -=item B +=item B %options> This will install an attribute of a given C<$name> into the current class. The list of C<%options> are the same as those provided by @@ -546,6 +546,59 @@ of the methods you want mapped. =back +=item B %options> + +This is variation on the normal attibute creator C, which allows you to +clone and extend an attribute from a superclass. Here is a quick example: + + package Foo; + use Moose; + + has 'message' => ( + is => 'rw', + isa => 'Str', + default => 'Hello, I am a Foo' + ); + + package My::Foo; + use Moose; + + extends 'Foo'; + + has '+message' => (default => 'Hello I am My::Foo'); + +What is happening here is that B is cloning the C attribute +from it's parent class B, retaining the is =E 'rw' and isa =E 'Str' +characteristics, but changing the value in C. + +This feature is restricted somewhat, so as to try and enfore at least I +sanity into it. You are only allowed to change the following attributes: + +=over 4 + +=item I + +Change the default value of an attribute. + +=item I + +Change whether the attribute attempts to coerce a value passed to it. + +=item I + +Change if the attribute is required to have a value. + +=item I + +Change the documentation string associated with the attribute. + +=item I + +You I allowed to change the type, but if and B the new type is +a subtype of the old type. + +=back + =item B sub { ... }> =item B sub { ... }>