summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-04-29 14:38:23 +0200
committerfranck cuny <franck@lumberjaph.net>2010-04-29 14:38:23 +0200
commit14d0bf15ab9cbc06fdc12ce11e473a35ab9372f3 (patch)
treeaf85fae6a2ea168a35a3783f7b53e5aaac7cbff5
parentuppercase, no need for ucfirst (diff)
downloadmoosex-privacy-14d0bf15ab9cbc06fdc12ce11e473a35ab9372f3.tar.gz
add count to attributes and methods
-rw-r--r--lib/MooseX/Privacy/Meta/Class/Role.pm10
-rw-r--r--t/10_private_method.t3
-rw-r--r--t/11_protected_method.t3
3 files changed, 9 insertions, 7 deletions
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 {
diff --git a/t/10_private_method.t b/t/10_private_method.t
index 9948983..f71ea57 100644
--- a/t/10_private_method.t
+++ b/t/10_private_method.t
@@ -56,8 +56,7 @@ with_immutable {
     isa_ok( $bar, 'Bar' );
     dies_ok { $bar->newbar() } "... can't call bar, method is private";
 
-    is scalar @{ $foo->meta->local_private_methods }, 2,
-        '... got two privates method';
+    is $foo->meta->_count_private_methods, 2, "... got two privates method";
 }
 (qw/Foo Bar/);
 
diff --git a/t/11_protected_method.t b/t/11_protected_method.t
index a7ef35f..dca8176 100644
--- a/t/11_protected_method.t
+++ b/t/11_protected_method.t
@@ -38,8 +38,7 @@ with_immutable {
     isa_ok( $bar, 'Bar' );
     is $bar->baz(), 'baz', "... got the good value from &bar";
 
-    is scalar @{ $foo->meta->local_protected_methods }, 1,
-        '... got one protected method';
+    is $foo->meta->_count_protected_methods, 1, "... got one protected method";
 }
 (qw/Foo Bar/);