diff options
Diffstat (limited to '')
-rw-r--r-- | lib/MooseX/Privacy.pm | 28 |
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> |