Stevan Little > Moose-0.34 > Moose::Cookbook::Recipe7

Download:
Moose-0.34.tar.gz

Annotate this POD (1)

CPAN RT

New  11
Open  40
Stalled  7
View/Report Bugs
Source   Latest Release: Moose-0.54

NAME ^

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

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"/>') 
  }

DESCRIPTION ^

Coming Soon.

CONCLUSION ^

FOOTNOTES ^

AUTHOR ^

Stevan Little <stevan@iinteractive.com>

COPYRIGHT AND LICENSE ^

Copyright 2007 by Infinity Interactive, Inc.

http://www.iinteractive.com

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

syntax highlighting: