summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-03-04 06:16:07 +0100
committerfranck cuny <franck@lumberjaph.net>2010-03-04 06:16:07 +0100
commitcda644c83656ca99dd9e24b52fa7cbb6e2f44198 (patch)
treecc09847cb15c2d57ea18967dd8d5bb5e99bf0837
parentstart to implement private and protected attributes (diff)
downloadmoosex-privacy-cda644c83656ca99dd9e24b52fa7cbb6e2f44198.tar.gz
add POD about private and protected traits
-rw-r--r--lib/MooseX/Privacy.pm28
1 files changed, 22 insertions, 6 deletions
diff --git a/lib/MooseX/Privacy.pm b/lib/MooseX/Privacy.pm
index 97ee6ac..172cf82 100644
--- a/lib/MooseX/Privacy.pm
+++ b/lib/MooseX/Privacy.pm
@@ -29,12 +29,6 @@ sub init_meta {
     );
 }
 
-package Moose::Meta::Attribute::Custom::Trait::Private;
-sub register_implementation { 'MooseX::Privacy::Trait::Private' }
-
-package Moose::Meta::Attribute::Custom::Trait::Protected;
-sub register_implementation { 'MooseX::Privacy::Trait::Protected' }
-
 1;
 __END__
 
@@ -46,6 +40,18 @@ MooseX::Privacy - Provides the syntax to restrict/control visibility of your met
 
   use MooseX::Privacy;
 
+  has config => (
+    is => 'rw',
+    isa => 'Some::Config',
+    traits => [qw/Private/],
+  );
+
+  has username => (
+    is => 'rw',
+    isa => 'Str',
+    traits => [qw/Protected/],
+  );
+
   private_method foo => sub {
     return 23;
   };
@@ -105,6 +111,16 @@ within the class AND any of it's subclasses.
     my $bar = Bar->new;
     $bar->bar;  # ok
 
+=head2 Attributes
+
+=head3 Private
+
+When the B<Private> traits is applied to an attribute, this attribute can only be read or set within the class.
+
+=head3 Protected
+
+When the B<Protected> traits is applied to an attribute, this attribute can only be read or set within the class AND any of his subclasses.
+
 =head1 AUTHOR
 
 franck cuny E<lt>franck@lumberjaph.netE<gt>