X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FCookbook%2FRecipe6.pod;h=6381776c67ee72a7935cadb4df4d22f6adef2b80;hb=1eca36fc96204137a3ddf5038610fde40c55e39e;hp=88911a398db41827310102c6881f329f99366a56;hpb=9e93dd19f8c035b497ddc9ed8a8628e66042015e;p=gitmo%2FMoose.git
diff --git a/lib/Moose/Cookbook/Recipe6.pod b/lib/Moose/Cookbook/Recipe6.pod
index 88911a3..6381776 100644
--- a/lib/Moose/Cookbook/Recipe6.pod
+++ b/lib/Moose/Cookbook/Recipe6.pod
@@ -3,85 +3,72 @@
=head1 NAME
-Moose::Cookbook::Recipe6 - The Moose::Role example
+Moose::Cookbook::Recipe6 - The augment/inner example
=head1 SYNOPSIS
-
- package Eq;
- use strict;
- use warnings;
- use Moose::Role;
+
+ package Document::Page;
+ use Moose;
- requires 'equal_to';
+ has 'body' => (is => 'rw', isa => 'Str', default => sub {''});
- sub not_equal_to {
- my ($self, $other) = @_;
- not $self->equal_to($other);
+ sub create {
+ my $self = shift;
+ $self->open_page;
+ inner();
+ $self->close_page;
}
- package Comparable;
- use strict;
- use warnings;
- use Moose::Role;
-
- with 'Eq';
-
- requires 'compare';
-
- sub equal_to {
- my ($self, $other) = @_;
- $self->compare($other) == 0;
- }
-
- sub greater_than {
- my ($self, $other) = @_;
- $self->compare($other) == 1;
- }
-
- sub less_than {
- my ($self, $other) = @_;
- $self->compare($other) == -1;
+ sub append_body {
+ my ($self, $appendage) = @_;
+ $self->body($self->body . $appendage);
}
- sub greater_than_or_equal_to {
- my ($self, $other) = @_;
- $self->greater_than($other) || $self->equal_to($other);
- }
+ sub open_page { (shift)->append_body('') }
+ sub close_page { (shift)->append_body('') }
- sub less_than_or_equal_to {
- my ($self, $other) = @_;
- $self->less_than($other) || $self->equal_to($other);
- }
-
- package Printable;
- use strict;
- use warnings;
- use Moose::Role;
+ package Document::PageWithHeadersAndFooters;
+ use Moose;
- requires 'to_string';
+ extends 'Document::Page';
- package US::Currency;
- use strict;
- use warnings;
- use Moose;
+ augment 'create' => sub {
+ my $self = shift;
+ $self->create_header;
+ inner();
+ $self->create_footer;
+ };
- with 'Comparable', 'Printable';
+ sub create_header { (shift)->append_body('') }
+ sub create_footer { (shift)->append_body('') }
- has 'amount' => (is => 'rw', isa => 'Num', default => 0);
+ package TPSReport;
+ use Moose;
- sub compare {
- my ($self, $other) = @_;
- $self->amount <=> $other->amount;
- }
+ extends 'Document::PageWithHeadersAndFooters';
- sub to_string {
+ augment 'create' => sub {
my $self = shift;
- sprintf '$%0.2f USD' => $self->amount
+ $self->create_tps_report;
+ };
+
+ sub create_tps_report {
+ (shift)->append_body('')
}
+ print TPSReport->new->create #
+
=head1 DESCRIPTION
-Coming Soon.
+Coming Soon.
+
+=head1 CONCLUSION
+
+=head1 FOOTNOTES
+
+=over 4
+
+=back
=head1 AUTHOR
@@ -89,7 +76,7 @@ Stevan Little Estevan@iinteractive.comE
=head1 COPYRIGHT AND LICENSE
-Copyright 2006 by Infinity Interactive, Inc.
+Copyright 2007 by Infinity Interactive, Inc.
L
@@ -97,4 +84,3 @@ This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
-
\ No newline at end of file