diff options
author | franck cuny <franck@lumberjaph.net> | 2010-02-10 16:37:42 +0100 |
---|---|---|
committer | franck cuny <franck@lumberjaph.net> | 2010-02-10 16:37:42 +0100 |
commit | 26c16f1c9431ddbcbd1d7bb85df106a12f2a9ef0 (patch) | |
tree | f4c4f500610b9cda418a6e40db6f09f39c7b97fd | |
parent | update POD (diff) | |
download | moosex-privacy-26c16f1c9431ddbcbd1d7bb85df106a12f2a9ef0.tar.gz |
update readme
-rw-r--r-- | README | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/README b/README index 950e8c0..95b819b 100644 --- a/README +++ b/README @@ -4,19 +4,55 @@ NAME SYNOPSIS use MooseX::Privacy; - private foo => sub { + private _foo => sub { return 23; }; - protect bar => sub { + protected _bar => sub { return 42; }; DESCRIPTION - MooseX::Privacy is + MooseX::Privacy brings the concept of private and protected methods to + your class. + + Private + When you declare a method as private, 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 + + Protected + When you declare a method as protected, 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 AUTHOR - franck cuny <franck.cuny@rtgi.fr> + franck cuny <franck@lumberjaph.net> SEE ALSO LICENSE |