From cda644c83656ca99dd9e24b52fa7cbb6e2f44198 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Thu, 4 Mar 2010 06:16:07 +0100 Subject: add POD about private and protected traits --- lib/MooseX/Privacy.pm | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'lib/MooseX') 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 traits is applied to an attribute, this attribute can only be read or set within the class. + +=head3 Protected + +When the B 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 Efranck@lumberjaph.netE -- cgit 1.4.1