Tidy the code (and clean up rampant wacky whitespace for RT 40432)
[gitmo/Moose.git] / lib / Moose / Cookbook / Basics / Recipe6.pod
1
2 =pod
3
4 =head1 NAME
5
6 Moose::Cookbook::Basics::Recipe6 - The augment/inner example
7
8 =head1 SYNOPSIS
9
10   package Document::Page;
11   use Moose;
12
13   has 'body' => ( is => 'rw', isa => 'Str', default => sub {''} );
14
15   sub create {
16       my $self = shift;
17       $self->open_page;
18       inner();
19       $self->close_page;
20   }
21
22   sub append_body {
23       my ( $self, $appendage ) = @_;
24       $self->body( $self->body . $appendage );
25   }
26
27   sub open_page  { (shift)->append_body('<page>') }
28   sub close_page { (shift)->append_body('</page>') }
29
30   package Document::PageWithHeadersAndFooters;
31   use Moose;
32
33   extends 'Document::Page';
34
35   augment 'create' => sub {
36       my $self = shift;
37       $self->create_header;
38       inner();
39       $self->create_footer;
40   };
41
42   sub create_header { (shift)->append_body('<header/>') }
43   sub create_footer { (shift)->append_body('<footer/>') }
44
45   package TPSReport;
46   use Moose;
47
48   extends 'Document::PageWithHeadersAndFooters';
49
50   augment 'create' => sub {
51       my $self = shift;
52       $self->create_tps_report;
53   };
54
55   sub create_tps_report {
56       (shift)->append_body('<report type="tps"/>');
57   }
58
59   # <page><header/><report type="tps"/><footer/></page>
60   print TPSReport->new->create;
61
62 =head1 DESCRIPTION
63
64 Coming Soon.
65
66 =head1 CONCLUSION
67
68 =head1 FOOTNOTES
69
70 =over 4
71
72 =back
73
74 =head1 AUTHOR
75
76 Stevan Little E<lt>stevan@iinteractive.comE<gt>
77
78 =head1 COPYRIGHT AND LICENSE
79
80 Copyright 2007 by Infinity Interactive, Inc.
81
82 L<http://www.iinteractive.com>
83
84 This library is free software; you can redistribute it and/or modify
85 it under the same terms as Perl itself.
86
87 =cut