restore documentation for lazy_build and underscore (_) prefixed operators
Chris Prather [Thu, 18 Nov 2010 18:59:32 +0000 (13:59 -0500)]
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.
(cherry picked from commit 970a92fa56f1ea409c8d7c5428392479292fd8d4)

lib/Moose/Cookbook/Basics/Recipe8.pod
lib/Moose/Meta/Attribute.pm

index 2d585c7..d748da9 100644 (file)
@@ -100,7 +100,7 @@ do the right thing with the C<predicate> and C<clearer>, making them
 both start with an underscore. The C<builder> method I<always> starts
 with an underscore.
 
-You can read more about C<lazy_build> in L<Moose::Manual::Attributes>
+You can read more about C<lazy_build> in L<Moose::Meta::Attribute>
 
 =head1 CONCLUSION
 
index 748b7ba..b4cb953 100644 (file)
@@ -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<<