From: Chris Prather Date: Thu, 18 Nov 2010 18:59:32 +0000 (-0500) Subject: restore documentation for lazy_build and underscore (_) prefixed operators X-Git-Tag: 1.9900~49 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=970a92fa56f1ea409c8d7c5428392479292fd8d4;p=gitmo%2FMoose.git restore documentation for lazy_build and underscore (_) prefixed operators It was removed from Moose::Manual::Attributes reasonably because it's discouraged. It needs to be documented somewhere, as confound says in the reference not the guide. Also updated the link in Recipe 8 to point to the reference. --- diff --git a/lib/Moose/Cookbook/Basics/Recipe8.pod b/lib/Moose/Cookbook/Basics/Recipe8.pod index 2d585c7..d748da9 100644 --- a/lib/Moose/Cookbook/Basics/Recipe8.pod +++ b/lib/Moose/Cookbook/Basics/Recipe8.pod @@ -100,7 +100,7 @@ do the right thing with the C and C, making them both start with an underscore. The C method I starts with an underscore. -You can read more about C in L +You can read more about C in L =head1 CONCLUSION diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index 1e8a6a3..882adc6 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -1039,6 +1039,29 @@ is equivalent to this: predicate => 'has_size', ); + +If your attribute name starts with an underscore (C<_>), then the clearer +and predicate will as well: + + has '_size' => ( + is => 'ro', + lazy_build => 1, + ); + +becomes: + + has '_size' => ( + is => 'ro', + lazy => 1, + builder => '_build__size', + clearer => '_clear_size', + predicate => '_has_size', + ); + +Note the doubled underscore in the builder name. Internally, Moose +simply prepends the attribute name with "_build_" to come up with the +builder name. + =item * documentation An arbitrary string that can be retrieved later by calling C<<