Commit | Line | Data |
---|---|---|
1a7ebbb3 | 1 | |
2 | package CountingClass; | |
3 | ||
4 | use strict; | |
5 | use warnings; | |
6 | ||
7 | use Class::MOP 'meta'; | |
8 | ||
9 | our $VERSION = '0.01'; | |
10 | ||
11 | __PACKAGE__->meta->superclasses('Class::MOP::Class'); | |
12 | ||
13 | __PACKAGE__->meta->add_attribute( | |
14 | Class::MOP::Attribute->new('$:count' => ( | |
15 | reader => 'get_count', | |
16 | default => 0 | |
17 | )) | |
18 | ); | |
19 | ||
20 | sub construct_instance { | |
21 | my ($class, %params) = @_; | |
22 | $class->{'$:count'}++; | |
23 | return $class->SUPER::construct_instance(); | |
24 | } | |
25 | ||
26 | 1; |