File: Recipe6.pod

package info (click to toggle)
libmoose-perl 0.54-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 1,496 kB
  • ctags: 448
  • sloc: perl: 15,125; makefile: 10
file content (86 lines) | stat: -rw-r--r-- 1,611 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

=pod

=head1 NAME

Moose::Cookbook::Recipe6 - The augment/inner example

=head1 SYNOPSIS
    
  package Document::Page;
  use Moose;
  
  has 'body' => (is => 'rw', isa => 'Str', default => sub {''});
  
  sub create {
      my $self = shift;
      $self->open_page;
      inner();
      $self->close_page;
  }
  
  sub append_body { 
      my ($self, $appendage) = @_;
      $self->body($self->body . $appendage);
  }
  
  sub open_page  { (shift)->append_body('<page>') }
  sub close_page { (shift)->append_body('</page>') }  
  
  package Document::PageWithHeadersAndFooters;
  use Moose;
  
  extends 'Document::Page';
  
  augment 'create' => sub {
      my $self = shift;
      $self->create_header;
      inner();
      $self->create_footer;
  };
  
  sub create_header { (shift)->append_body('<header/>') }
  sub create_footer { (shift)->append_body('<footer/>') }  
  
  package TPSReport;
  use Moose;
  
  extends 'Document::PageWithHeadersAndFooters';
  
  augment 'create' => sub {
      my $self = shift;
      $self->create_tps_report;
  };
  
  sub create_tps_report {
     (shift)->append_body('<report type="tps"/>') 
  }
  
  print TPSReport->new->create # <page><header/><report type="tps"/><footer/></page>

=head1 DESCRIPTION

Coming Soon.

=head1 CONCLUSION

=head1 FOOTNOTES

=over 4

=back

=head1 AUTHOR

Stevan Little E<lt>stevan@iinteractive.comE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright 2007 by Infinity Interactive, Inc.

L<http://www.iinteractive.com>

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=cut