summary refs log tree commit diff
path: root/lib/MooseX/Privacy.pm
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-02-10 16:32:12 +0100
committerfranck cuny <franck@lumberjaph.net>2010-02-10 16:32:12 +0100
commitaf282540edaacdbdb598111ae094b027629b6570 (patch)
tree46b2f0952407cc3e38b10a0808cd1fab0510e19c /lib/MooseX/Privacy.pm
parentupdate readme, need to write POD now (diff)
downloadmoosex-privacy-af282540edaacdbdb598111ae094b027629b6570.tar.gz
update POD
Diffstat (limited to 'lib/MooseX/Privacy.pm')
-rw-r--r--lib/MooseX/Privacy.pm46
1 files 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<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
+
+=head2 Protected
+
+When you declare a method as B<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
 
 =head1 AUTHOR
 
-franck cuny E<lt>franck.cuny@rtgi.frE<gt>
+franck cuny E<lt>franck@lumberjaph.netE<gt>
 
 =head1 SEE ALSO