bah
[gitmo/Moose.git] / lib / Moose / Cookbook / Recipe6.pod
1
2 =pod
3
4 =head1 NAME
5
6 Moose::Cookbook::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   print TPSReport->new->create # <page><header/><report type="tps"/><footer/></page>
60
61 =head1 DESCRIPTION
62
63 Coming Soon.
64
65 =head1 CONCLUSION
66
67 =head1 FOOTNOTES
68
69 =over 4
70
71 =back
72
73 =head1 AUTHOR
74
75 Stevan Little E<lt>stevan@iinteractive.comE<gt>
76
77 =head1 COPYRIGHT AND LICENSE
78
79 Copyright 2007 by Infinity Interactive, Inc.
80
81 L<http://www.iinteractive.com>
82
83 This library is free software; you can redistribute it and/or modify
84 it under the same terms as Perl itself.
85
86 =cut