From: Dave Rolsky Date: Thu, 4 Sep 2008 21:35:50 +0000 (+0000) Subject: Add an example of delegation too. X-Git-Tag: 0.58~48 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b1ff769c3d49b7c4a8831aa23eb32c05e00d515e;p=gitmo%2FMoose.git Add an example of delegation too. --- diff --git a/lib/Moose/Unsweetened.pod b/lib/Moose/Unsweetened.pod index e72b08a..ca0d7ee 100644 --- a/lib/Moose/Unsweetened.pod +++ b/lib/Moose/Unsweetened.pod @@ -41,9 +41,10 @@ First, we define two very small classes the Moose way. => via { $en_parser->parse_datetime($_) }; has birth_date => ( - is => 'rw', - isa => 'DateTime', - coerce => 1, + is => 'rw', + isa => 'DateTime', + coerce => 1, + handles => { birth_year => 'year' }, ); subtype 'ShirtSize' @@ -196,6 +197,12 @@ helpers like C. return $self->{birth_date}; } + sub birth_year { + my $self = shift; + + return $self->birth_date->year; + } + sub shirt_size { my $self = shift;