Good object-oriented code should allow itself to be subclassed
gracefully. Let's tweak C<_build_child_tree>:
- sub _build_child_tree
+ sub _build_child_tree {
my $self = shift;
return (ref $self)->new( parent => $self, @_ );
return Cat->new();
}
-This simply could not be done using a C<default>.
-
=head2 The lazy_build shortcut
The C<lazy_build> attribute parameter can be used as sugar to specify
with an underscore, since you will want this to be private the vast
majority of the time.
+Note that the C<builder> method name is created by simply taking
+"_build_" and appending the attribute name. This means that attributes
+with a leading underscore like C<_animal> end up with a builder named
+C<_build__animal>.
+
=head1 CONCLUSION
The C<builder> option is a more OO-friendly version of the C<default>