From: Dave Rolsky Date: Sun, 3 May 2009 18:08:01 +0000 (-0500) Subject: Fix aroun example to handle both read & write cases correctly. X-Git-Tag: 0.78~43 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=24d8fc0d25a900ff31bacf7744b2e3ab99aa16ab;p=gitmo%2FMoose.git Fix aroun example to handle both read & write cases correctly. --- diff --git a/lib/Moose/Cookbook/FAQ.pod b/lib/Moose/Cookbook/FAQ.pod index b8f372a..3fd9e02 100644 --- a/lib/Moose/Cookbook/FAQ.pod +++ b/lib/Moose/Cookbook/FAQ.pod @@ -167,9 +167,13 @@ is to add an C modifier to your accessor: around 'timestamp' => sub { my $next = shift; - my ($self, $timestamp) = @_; + my $self = shift; + + return $self->$next unless @_; + # assume we get a DateTime object ... - $self->$next( $timestamp->epoch ); + my $timestamp = shift; + return $self->$next( $timestamp->epoch ); }; It is also possible to do deflation using coercion, but this tends