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=ed8d57212e332b0b1872d892edafd786b4589ffa;hpb=a7d0cd00a63c674bb47b228e7d1158db25968e16;p=gitmo%2FMoose.git
diff --git a/lib/Moose/Cookbook/Recipe6.pod b/lib/Moose/Cookbook/Recipe6.pod
index ed8d572..6381776 100644
--- a/lib/Moose/Cookbook/Recipe6.pod
+++ b/lib/Moose/Cookbook/Recipe6.pod
@@ -3,100 +3,72 @@
=head1 NAME
-Moose::Cookbook::Recipe6 - The Moose::Role example
+Moose::Cookbook::Recipe6 - The augment/inner example
=head1 SYNOPSIS
+
+ package Document::Page;
+ use Moose;
- package Constraint;
- use strict;
- use warnings;
- use Moose::Role;
-
- has 'value' => (isa => 'Int', is => 'ro');
+ has 'body' => (is => 'rw', isa => 'Str', default => sub {''});
- around 'validate' => sub {
- my $c = shift;
- my ($self, $field) = @_;
- if ($c->($self, $self->validation_value($field))) {
- return undef;
- }
- else {
- return $self->error_message;
- }
- };
+ sub create {
+ my $self = shift;
+ $self->open_page;
+ inner();
+ $self->close_page;
+ }
- sub validation_value {
- my ($self, $field) = @_;
- return $field;
+ sub append_body {
+ my ($self, $appendage) = @_;
+ $self->body($self->body . $appendage);
}
- sub error_message { confess "Abstract method!" }
+ sub open_page { (shift)->append_body('') }
+ sub close_page { (shift)->append_body('') }
- package Constraint::OnLength;
- use strict;
- use warnings;
- use Moose::Role;
+ package Document::PageWithHeadersAndFooters;
+ use Moose;
- has 'units' => (isa => 'Str', is => 'ro');
+ extends 'Document::Page';
- override 'validation_value' => sub {
- return length(super());
+ augment 'create' => sub {
+ my $self = shift;
+ $self->create_header;
+ inner();
+ $self->create_footer;
};
- override 'error_message' => sub {
- my $self = shift;
- return super() . ' ' . $self->units;
- };
+ sub create_header { (shift)->append_body('') }
+ sub create_footer { (shift)->append_body('') }
- package Constraint::AtLeast;
- use strict;
- use warnings;
+ package TPSReport;
use Moose;
- with 'Constraint';
-
- sub validate {
- my ($self, $field) = @_;
- ($field >= $self->value);
- }
-
- sub error_message { 'must be at least ' . (shift)->value; }
-
- package Constraint::NoMoreThan;
- use strict;
- use warnings;
- use Moose;
+ extends 'Document::PageWithHeadersAndFooters';
- with 'Constraint';
+ augment 'create' => sub {
+ my $self = shift;
+ $self->create_tps_report;
+ };
- sub validate {
- my ($self, $field) = @_;
- ($field <= $self->value);
+ sub create_tps_report {
+ (shift)->append_body('')
}
- sub error_message { 'must be no more than ' . (shift)->value; }
-
- package Constraint::LengthNoMoreThan;
- use strict;
- use warnings;
- use Moose;
-
- extends 'Constraint::NoMoreThan';
- with 'Constraint::OnLength';
-
- package Constraint::LengthAtLeast;
- use strict;
- use warnings;
- use Moose;
-
- extends 'Constraint::AtLeast';
- with 'Constraint::OnLength';
-
+ print TPSReport->new->create #
+
=head1 DESCRIPTION
-Coming Soon.
+Coming Soon.
+
+=head1 CONCLUSION
+
+=head1 FOOTNOTES
+
+=over 4
-(the other 4 recipes kinda burned me out a bit)
+=back
=head1 AUTHOR
@@ -104,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
@@ -112,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