summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-06-19 15:08:51 +0200
committerfranck cuny <franck@lumberjaph.net>2010-06-19 15:08:51 +0200
commitf9de2becaaca0b01dfb98334be00f27b8cbf05f4 (patch)
tree384312da06c404c842d0d696498d141c3263c32f
parentuse new role to generate method (diff)
downloadmoosex-privacy-f9de2becaaca0b01dfb98334be00f27b8cbf05f4.tar.gz
some tidy
-rw-r--r--lib/MooseX/Privacy/Meta/Class/Role.pm18
-rw-r--r--t/14_private_attribute.t40
-rw-r--r--t/15_protected_attribute.t34
3 files changed, 50 insertions, 42 deletions
diff --git a/lib/MooseX/Privacy/Meta/Class/Role.pm b/lib/MooseX/Privacy/Meta/Class/Role.pm
index 3640e21..76d3ca4 100644
--- a/lib/MooseX/Privacy/Meta/Class/Role.pm
+++ b/lib/MooseX/Privacy/Meta/Class/Role.pm
@@ -14,14 +14,16 @@ role {
     my $p = shift;
 
     my $name             = $p->name;
-    my $local_methods    = "local_" . $name . "_methods";
-    my $local_attributes = "local_" . $name . "_attributes";
-    my $push_method      = "_push_" . $name . "_method";
-    my $push_attribute   = "_push_" . $name . "_attribute";
-    my $count_methods    = "_count_" . $name . "_methods";
-    my $count_attributes = "_count_" . $name . "_attributes";
-
-    my $meta_method = "add_" . $name . "_method";
+    my $local_methods        = "local_" . $name . "_methods";
+    my $local_attributes     = "local_" . $name . "_attributes";
+    my $push_method          = "_push_" . $name . "_method";
+    my $push_attribute       = "_push_" . $name . "_attribute";
+    my $count_methods        = "_count_" . $name . "_methods";
+    my $count_attributes     = "_count_" . $name . "_attributes";
+    my $get_method           = 'get_' . $name . '_method';
+    my $get_all_mehods       = 'get_all_' . $name . '_methods';
+    my $get_all_methods_name = 'get_all_' . $name . '_method_names';
+    my $meta_method          = "add_" . $name . "_method";
 
     has $local_methods => (
         traits     => ['Array'],
diff --git a/t/14_private_attribute.t b/t/14_private_attribute.t
index 811294a..0050298 100644
--- a/t/14_private_attribute.t
+++ b/t/14_private_attribute.t
@@ -5,22 +5,34 @@ use Test::More tests => 10;
 use Test::Exception;
 use Test::Moose;
 
-{
-
-    package Foo;
-    use Moose;
-    use MooseX::Privacy;
-
-    has foo => ( is => 'rw', isa => 'Str', traits => [qw/Private/] );
-    sub bar { my $self = shift; $self->foo('bar'); $self->foo }
+package Foo;
+use Moose;
+use MooseX::Privacy;
+
+has foo => (
+    is      => 'rw',
+    isa     => 'Str',
+    lazy    => 1,
+    default => 'test',
+    traits  => [qw/Private/]
+);
+
+sub bar {
+    my $self = shift;
+    $self->foo('bar');
+    $self->foo;
 }
 
-{
+package Bar;
+use Moose;
 
-    package Bar;
-    use Moose;
-    has bar => ( is => 'rw', isa => 'Str', traits => [qw/Private/] );
-}
+has bar => (
+    is => 'rw',
+    isa => 'Str',
+    traits => [qw/Private/]
+);
+
+package main;
 
 with_immutable {
     ok my $foo = Foo->new();
@@ -31,5 +43,3 @@ with_immutable {
     ok my $bar = Bar->new();
 }
 (qw/Foo Bar/);
-
-
diff --git a/t/15_protected_attribute.t b/t/15_protected_attribute.t
index fe3fd9a..36e8f66 100644
--- a/t/15_protected_attribute.t
+++ b/t/15_protected_attribute.t
@@ -5,28 +5,24 @@ use Test::More tests => 10;
 use Test::Exception;
 use Test::Moose;
 
-{
-
-    package Foo;
-    use Moose;
-    use MooseX::Privacy;
-
-    has foo => (
-        is      => 'rw',
-        isa     => 'Str',
-        traits  => [qw/Protected/],
-        default => 'foo'
-    );
-}
+package Foo;
+use Moose;
+use MooseX::Privacy;
 
-{
+has foo => (
+    is      => 'rw',
+    isa     => 'Str',
+    traits  => [qw/Protected/],
+    default => 'foo'
+);
 
-    package Bar;
-    use Moose;
-    extends 'Foo';
+package Bar;
+use Moose;
+extends 'Foo';
 
-    sub bar { (shift)->foo }
-}
+sub bar { (shift)->foo }
+
+package main;
 
 with_immutable {
     ok my $foo = Foo->new();