The behaviour of weak_ref attributes and predicate may be surprising to some; document that in this instance, 'has_foo' does not return whether the object has an attribute, just that it 'had' the attribute. --- lib/Moose.pm | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/lib/Moose.pm b/lib/Moose.pm index 9912e2c..2ee9ba0 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -474,7 +474,8 @@ say anything about the attribute's value, which can be C<undef>. This will tell the class to store the value of this attribute as a weakened reference. If an attribute is a weakened reference, it B<cannot> also be -coerced. +coerced. Note that when weak refs expire, they are still considered 'set' +in terms of predicate, default, etc. =item I<lazy =E<gt> (1|0)> @@ -682,6 +683,9 @@ information. Creates a method to perform a basic test to see if a value has been set in the attribute. See the L<predicate option docs in Class::MOP::Attribute|Class::MOP::Attribute/predicate> for more information. +This checks that the slot has been created (exists), so if your attribute is +set to be a weak_ref then the predicate may return true when there is no actual +value there. =item I<lazy_build> => (0|1) -- 1.7.0.4
