From: Jesse Luehrs Date: Sat, 7 May 2011 00:37:14 +0000 (-0500) Subject: grammar and formatting cleanups X-Git-Tag: 2.0100~151 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ed809fa3280e7237b9fa5b618cfc78467e499aaf;p=gitmo%2FMoose.git grammar and formatting cleanups --- diff --git a/lib/Moose/Manual/FAQ.pod b/lib/Moose/Manual/FAQ.pod index 8052982..3488617 100644 --- a/lib/Moose/Manual/FAQ.pod +++ b/lib/Moose/Manual/FAQ.pod @@ -271,16 +271,22 @@ Not yet. This option may come in a future release. =head3 My coercions stopped working with recent Moose, why did you break it? -Moose 0.76 fixed a case where Coercions were being applied even if the original constraint passed. This has caused some edge cases to fail where people were doing something like +Moose 0.76 fixed a case where coercions were being applied even if the original +constraint passed. This has caused some edge cases to fail where people were +doing something like - subtype Address => as 'Str'; - coerce Address => from Str => via { get_address($_) }; + subtype 'Address', as 'Str'; + coerce 'Address', from 'Str', via { get_address($_) }; -Which is not what they intended. The Type Constraint C
is too loose in this case, it is saying that all Strings are Addresses, which is obviously not the case. The solution is to provide a where clause that properly restricts the Type Constraint. +This is not what they intended, because the type constraint C
is too +loose in this case. It is saying that all strings are Addresses, which is +obviously not the case. The solution is to provide a C clause that +properly restricts the type constraint: - subtype Address => as Str => where { looks_like_address($_) }; + subtype 'Address', as 'Str', where { looks_like_address($_) }; -This will allow the coercion to apply only to strings that fail to look like an Address. +This will allow the coercion to apply only to strings that fail to look like an +Address. =head2 Roles