From: Jesse Luehrs Date: Fri, 1 Oct 2010 04:56:25 +0000 (-0500) Subject: docs for weaken X-Git-Tag: 1.10~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f035b141c7228eea7b709f06f20178782f0e29ee;p=gitmo%2FClass-MOP.git docs for weaken --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 38b11f9..6648927 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -1478,6 +1478,21 @@ Specifies the name to install the C method for this class under. If it is not passed, C is assumed, and if C is explicitly given, no meta method will be installed. +=item * weaken + +If true, the metaclass that is stored in the global cache will be a +weak reference. + +Classes created in this way are destroyed once the metaclass they are +attached to goes out of scope, and will be removed from Perl's internal +symbol table. + +All instances of a class with a weakened metaclass keep a special +reference to the metaclass object, which prevents the metaclass from +going out of scope while any instances exist. + +This only works if the instance is based on a hash reference, however. + =back =item B<< Class::MOP::Class->create_anon_class(%options) >> @@ -1489,15 +1504,8 @@ that name is a unique name generated internally by this module. It accepts the same C, C, and C parameters that C accepts. -Anonymous classes are destroyed once the metaclass they are attached -to goes out of scope, and will be removed from Perl's internal symbol -table. - -All instances of an anonymous class keep a special reference to the -metaclass object, which prevents the metaclass from going out of scope -while any instances exist. - -This only works if the instance is based on a hash reference, however. +Anonymous classes default to C<< weaken => 1 >>, although this can be +overridden. =item B<< Class::MOP::Class->initialize($package_name, %options) >>