X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FManual%2FAttributes.pod;fp=lib%2FMoose%2FManual%2FAttributes.pod;h=9381a69e7593d9ce816935da09405f3d6585cfcd;hb=01fd70ed5d41bcfa561c198b172c594bc3256760;hp=35bcaed7cb2e5b2ca428a231689d6b28ca2f7839;hpb=f68fa9b44fabe868c890b7e489e64c8ebc47b22f;p=gitmo%2FMoose.git diff --git a/lib/Moose/Manual/Attributes.pod b/lib/Moose/Manual/Attributes.pod index 35bcaed..9381a69 100644 --- a/lib/Moose/Manual/Attributes.pod +++ b/lib/Moose/Manual/Attributes.pod @@ -617,6 +617,24 @@ to C<'Bill'>. We recommend that you exercise caution when changing the type (C) of an inherited attribute. +=head1 MULTIPLE ATTRIBUTE SHORTCUTS + +If you have a number of attributes that differ only be name, you can declare +them all at once: + + package Point; + + use Moose; + + has [ 'x', 'y' ] => ( is => 'ro', isa => 'Int' ); + +Also, because C is just a function call, you can call it in a loop: + + for my $name ( qw( x y ) ) { + my $builder = '_build_' . $name; + has $name => ( is => 'ro', isa => 'Int', builder => $builder ); + } + =head1 MORE ON ATTRIBUTES Moose attributes are a big topic, and this document glosses over a few