From: Dave Rolsky Date: Mon, 19 May 2008 15:22:35 +0000 (+0000) Subject: Try to clarify when builder methods are called, and what their X-Git-Tag: 0_55~162 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e89d3090fc6248435dd895c6c69e7ca189aef083;p=gitmo%2FMoose.git Try to clarify when builder methods are called, and what their invocant is. --- diff --git a/lib/Moose/Cookbook/Recipe9.pod b/lib/Moose/Cookbook/Recipe9.pod index c58bd3f..9ccf92a 100644 --- a/lib/Moose/Cookbook/Recipe9.pod +++ b/lib/Moose/Cookbook/Recipe9.pod @@ -52,10 +52,21 @@ If you've already read L, then this example should look awfully familiar. In fact, all we've done here is replace the attribute C with a C method. -In this particular case, the C and C act exactly the -same. When the C or C attribute is first accessed before -it has been set, Moose will call the specified C method to -populate the attribute. +In this particular case, the C and C options act in +exactly the same way. When the C or C attribute get +method is called, Moose will call the builder method to initialize the +attribute. + +Note that Moose calls the builder method I. Here's an example in code: + + my $tree = BinaryTree->new(); + + my $left = $tree->left(); + +At this point, Moose will call C<< $tree->_build_child_tree() >> in +order to populate the C attribute. If we had passed C to +the original constructor, the builer would not be called. =head2 Subclassable