From 14d0bf15ab9cbc06fdc12ce11e473a35ab9372f3 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Thu, 29 Apr 2010 14:38:23 +0200 Subject: add count to attributes and methods --- lib/MooseX/Privacy/Meta/Class/Role.pm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/MooseX/Privacy/Meta') diff --git a/lib/MooseX/Privacy/Meta/Class/Role.pm b/lib/MooseX/Privacy/Meta/Class/Role.pm index cb7e03a..7357c2e 100644 --- a/lib/MooseX/Privacy/Meta/Class/Role.pm +++ b/lib/MooseX/Privacy/Meta/Class/Role.pm @@ -18,7 +18,10 @@ role { my $local_attributes = "local_" . $name . "_attributes"; my $push_method = "_push_" . $name . "_method"; my $push_attribute = "_push_" . $name . "_attribute"; - my $meta_method = "add_" . $name . "_method"; + my $count_methods = "_count_" . $name . "_methods"; + my $count_attributes = "_count_" . $name . "_attributes"; + + my $meta_method = "add_" . $name . "_method"; has $local_methods => ( traits => ['Array'], @@ -27,7 +30,7 @@ role { required => 1, default => sub { [] }, auto_deref => 1, - handles => { $push_method => 'push' }, + handles => { $push_method => 'push', $count_methods => 'count' }, ); has $local_attributes => ( @@ -37,7 +40,8 @@ role { required => 1, default => sub { [] }, auto_deref => 1, - handles => { $push_attribute => 'push' }, + handles => + { $push_attribute => 'push', $count_attributes => 'count' }, ); method $meta_method => sub { -- cgit 1.4.1