X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FCookbook%2FBasics%2FRecipe6.pod;h=9d4d633bbeb7dba6af5e486dec57d7b19c8a3bf8;hb=56631d7a6a6b033c357239d5ac74b598b371cb41;hp=9fb42ddce5f4cf3d9bb1a6e21adb23bd284cd99e;hpb=f1c9feb4c023e53dfd08b4b28298a662bce6e5ec;p=gitmo%2FMoose.git
diff --git a/lib/Moose/Cookbook/Basics/Recipe6.pod b/lib/Moose/Cookbook/Basics/Recipe6.pod
index 9fb42dd..9d4d633 100644
--- a/lib/Moose/Cookbook/Basics/Recipe6.pod
+++ b/lib/Moose/Cookbook/Basics/Recipe6.pod
@@ -50,6 +50,7 @@ Moose::Cookbook::Basics::Recipe6 - The augment/inner example
augment 'create' => sub {
my $self = shift;
$self->create_tps_report;
+ inner();
};
sub create_tps_report {
@@ -57,31 +58,92 @@ Moose::Cookbook::Basics::Recipe6 - The augment/inner example
}
#
- print TPSReport->new->create;
+ my $report_xml = TPSReport->new->create;
=head1 DESCRIPTION
-Coming Soon.
+This recipe shows how the C method modifier works. This
+modifier reverses the normal subclass to parent method resolution
+order. With an C modifier the I specific method is
+called first. Each successive call to C descends the
+inheritance tree, ending at the most specific subclass.
-=head1 CONCLUSION
+The C modifier lets you design a parent class that can be
+extended in a specific way. The parent provides generic wrapper
+functionality, and the subclasses fill in the details.
+
+In the example above, we've created a set of document classes, with
+the most specific being the C class.
-=head1 FOOTNOTES
+We start with the least specific class, C. Its create
+method contains a call to C:
-=over 4
+ sub create {
+ my $self = shift;
+ $self->open_page;
+ inner();
+ $self->close_page;
+ }
+
+The C function is exported by C, and is like C
+for augmented methods. When C is called, Moose finds the next
+method in the chain, which is the C modifier in
+C. You'll note that we can call
+C in our modifier:
+
+ augment 'create' => sub {
+ my $self = shift;
+ $self->create_header;
+ inner();
+ $self->create_footer;
+ };
-=back
+This finds the next most specific modifier, in the C class.
+
+Finally, in the C class, the chain comes to an end:
+
+ augment 'create' => sub {
+ my $self = shift;
+ $self->create_tps_report;
+ inner();
+ };
+
+We do call the C function one more time, but since there is no
+more specific subclass, this is a no-op. Making this call means we can
+easily subclass C in the future.
+
+=head1 CONCLUSION
+
+The C modifier is a powerful tool for creating a set of
+nested wrappers. It's not something you will need often, but when you
+do, it is very handy.
=head1 AUTHOR
Stevan Little Estevan@iinteractive.comE
+Dave Rolsky Eautarch@urth.orgE
+
=head1 COPYRIGHT AND LICENSE
-Copyright 2007 by Infinity Interactive, Inc.
+Copyright 2007-2010 by Infinity Interactive, Inc.
L
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
-=cut
+=begin testing
+
+my $tps_report = TPSReport->new;
+isa_ok( $tps_report, 'TPSReport' );
+
+is(
+ $tps_report->create,
+ q{},
+ '... got the right TPS report'
+);
+
+=end testing
+
+=cut