fixed the test for method modifiers
[gitmo/Moose.git] / lib / Moose / Cookbook / Recipe6.pod
CommitLineData
a909a4df 1
2=pod
3
4=head1 NAME
5
496b74ab 6Moose::Cookbook::Recipe6 - The augment/inner example
a909a4df 7
8=head1 SYNOPSIS
d876e049 9
a909a4df 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
d876e049 27 sub open_page { (shift)->append_body('<page>') }
28 sub close_page { (shift)->append_body('</page>') }
a909a4df 29
d876e049 30 package Document::PageWithHeadersAndFooters;
a909a4df 31 use Moose;
32
33 extends 'Document::Page';
34
d876e049 35 augment 'create' => sub {
a909a4df 36 my $self = shift;
37 $self->create_header;
38 inner();
39 $self->create_footer;
d876e049 40 };
a909a4df 41
42 sub create_header { (shift)->append_body('<header/>') }
43 sub create_footer { (shift)->append_body('<footer/>') }
44
d876e049 45 package TPSReport;
a909a4df 46 use Moose;
47
d876e049 48 extends 'Document::PageWithHeadersAndFooters';
a909a4df 49
d876e049 50 augment 'create' => sub {
a909a4df 51 my $self = shift;
52 $self->create_tps_report;
53 };
54
55 sub create_tps_report {
56 (shift)->append_body('<report type="tps"/>')
57 }
004222dc 58
59 print TPSReport->new->create # <page><header/><report type="tps"/><footer/></page>
a909a4df 60
61=head1 DESCRIPTION
62
7125b244 63Coming Soon.
64
a909a4df 65=head1 CONCLUSION
66
67=head1 FOOTNOTES
68
69=over 4
70
71=back
72
73=head1 AUTHOR
74
75Stevan Little E<lt>stevan@iinteractive.comE<gt>
76
77=head1 COPYRIGHT AND LICENSE
78
7125b244 79Copyright 2007 by Infinity Interactive, Inc.
a909a4df 80
81L<http://www.iinteractive.com>
82
83This library is free software; you can redistribute it and/or modify
84it under the same terms as Perl itself.
85
86=cut