From: Yuval Kogman Date: Mon, 6 Jul 2009 05:18:17 +0000 (-0500) Subject: Add example for private writer X-Git-Tag: 0.87~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8a68781da0a1c7b8b019ff5347283dc38aea43b4;p=gitmo%2FMoose.git Add example for private writer --- diff --git a/lib/Moose/Manual/BestPractices.pod b/lib/Moose/Manual/BestPractices.pod index 06deb84..0e79409 100644 --- a/lib/Moose/Manual/BestPractices.pod +++ b/lib/Moose/Manual/BestPractices.pod @@ -113,6 +113,15 @@ If you I make an attribute read-write, consider making the writer a separate private method. Narrower APIs are easy to maintain, and mutable state is trouble. +In order to declare such attributes, provide a private C +parameter: + + has pizza => ( + isa => "Pizza", + is => "ro", + writer => "_pizza", + ); + =head2 Think twice before changing an attribute's type in a subclass Down this path lies great confusion. If the attribute is an object