From: Paul Driver Date: Fri, 18 Jul 2008 20:16:22 +0000 (+0000) Subject: Updated some documentation X-Git-Tag: 0_55~46^2~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=953e657e0aaf23b2ae9bdfad42f57409eaa47a0f;p=gitmo%2FMoose.git Updated some documentation --- diff --git a/lib/Moose.pm b/lib/Moose.pm index ecc8801..a74108d 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -454,13 +454,16 @@ If an attribute is marked as lazy it B have a default supplied. This tells the accessor whether to automatically dereference the value returned. This is only legal if your C option is either C or C. -=item I $code> - -The I option is a CODE reference which will be called after the value of -the attribute is set. The CODE ref will be passed the instance itself, the -updated value and the attribute meta-object (this is for more advanced fiddling -and can typically be ignored). You B have a trigger on a read-only -attribute. +=item I $code or $hash> + +The I option is a CODE reference which will be called after the value +of the attribute is set. The CODE ref will be passed the instance itself, the +updated value and the attribute meta-object (this is for more advanced +fiddling and can typically be ignored). You B have a trigger on a +read-only attribute. It can optionally be a hashref of before/after/around to +CODE refs, in which case after/before behave as in the plain CODE ref case, +and around first gets a CODE ref which takes the rest of the args and sets the +value. =item I ARRAY | HASH | REGEXP | ROLE | CODE> diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index 1ad7550..21765b3 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -955,6 +955,11 @@ value of an attribute is assigned. The CODE ref will get two values, the invocant and the new value. This can be used to handle I bi-directional relations. +This can also be a HASH of CODE refs for before/around/after, much +in the same vein as method modifiers. After and before work just +like the plain CODE ref case. Around first gets a CODE ref that +expects the rest of the args and will assign the value. + =item B This is a string which contains the documentation for this attribute.