X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=examples%2FInstanceCountingClass.pod;h=b28fef88a403e68ce51e6f4f8da68e359dc29c86;hb=d83eddd0c97e4828272ea7a174731437ac36ebf1;hp=5730517b7cc664df2c9c0fa3b7606d796503a149;hpb=5659d76e5bb87873fa7c80efdf1cce8c40d40237;p=gitmo%2FClass-MOP.git diff --git a/examples/InstanceCountingClass.pod b/examples/InstanceCountingClass.pod index 5730517..b28fef8 100644 --- a/examples/InstanceCountingClass.pod +++ b/examples/InstanceCountingClass.pod @@ -5,22 +5,19 @@ package # hide the package from PAUSE use strict; use warnings; -our $VERSION = '0.02'; +our $VERSION = '0.03'; use base 'Class::MOP::Class'; -__PACKAGE__->meta->add_attribute( - Class::MOP::Attribute->new('$:count' => ( - reader => 'get_count', - default => 0 - )) -); +InstanceCountingClass->meta->add_attribute('count' => ( + reader => 'get_count', + default => 0 +)); -sub construct_instance { - my ($class, %params) = @_; - $class->{'$:count'}++; - return $class->SUPER::construct_instance(); -} +InstanceCountingClass->meta->add_before_method_modifier('_construct_instance' => sub { + my ($class) = @_; + $class->{'count'}++; +}); 1; @@ -58,13 +55,15 @@ InstanceCountingClass - An example metaclass which counts instances This is a classic example of a metaclass which keeps a count of each instance which is created. -=head1 AUTHOR +=head1 AUTHORS Stevan Little Estevan@iinteractive.comE +Yuval Kogman Enothingmuch@woobling.comE + =head1 COPYRIGHT AND LICENSE -Copyright 2006 by Infinity Interactive, Inc. +Copyright 2006-2008 by Infinity Interactive, Inc. L