From af282540edaacdbdb598111ae094b027629b6570 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Wed, 10 Feb 2010 16:32:12 +0100 Subject: update POD --- lib/MooseX/Privacy.pm | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/lib/MooseX/Privacy.pm b/lib/MooseX/Privacy.pm index 4794a14..cd3d956 100644 --- a/lib/MooseX/Privacy.pm +++ b/lib/MooseX/Privacy.pm @@ -40,21 +40,59 @@ MooseX::Privacy - Provides syntax to enable privacy on your methods use MooseX::Privacy; - private foo => sub { + private _foo => sub { return 23; }; - protect bar => sub { + protected _bar => sub { return 42; }; =head1 DESCRIPTION -MooseX::Privacy is +MooseX::Privacy brings the concept of private and protected methods to your +class. + +=head2 Private + +When you declare a method as B, the method can be called only within +the class. + + package Foo; + use Moose; + use MooseX::Privacy; + private _foo => sub { return 23 }; + sub foo { my $self = shift; $self->_foo } + 1; + + my $foo = Foo->new; + $foo->_foo; # die + $foo->foo; # ok + +=head2 Protected + +When you declare a method as B, the method can be called only +within the class AND any subclasses. + + package Foo; + use Moose; + use MooseX::Privacy; + protected _foo => sub { return 23 }; + + package Bar; + use Moose; + extends Foo; + sub foo { my $self = shift; $self->_foo } + 1; + + my $foo = Foo->new; + $foo->_foo; # die + my $bar = Bar->new; + $bar->foo; # ok =head1 AUTHOR -franck cuny Efranck.cuny@rtgi.frE +franck cuny Efranck@lumberjaph.netE =head1 SEE ALSO -- cgit 1.4.1