-
-
15 Feb 2011 09:10:08 UTC
- Distribution: MooseX-Privacy
- Module version: 0.05
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues (3)
- Testers (4530 / 26 / 0)
- Kwalitee
Bus factor: 0- % Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (14.61KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
NAME
MooseX::Privacy - Provides the syntax to restrict/control visibility of your methods
VERSION
version 0.05
SYNOPSIS
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; }; protected_method bar => sub { return 42; };
DESCRIPTION
MooseX::Privacy brings the concept of private and protected methods to your class.
METHODS
Private
When you declare a method as private, this method can be called only within the class.
package Foo; use Moose; use MooseX::Privacy; private_method foo => sub { return 23 }; sub mul_by_foo { my $self = shift; $self->foo * $_[0] } 1; my $foo = Foo->new; $foo->foo; # die $foo->mul_by_foo; # ok
Protected
When you declare a method as protected, this method can be called only within the class AND any of it's subclasses.
package Foo; use Moose; use MooseX::Privacy; protected_method foo => sub { return 23 }; package Bar; use Moose; extends Foo; sub bar { my $self = shift; $self->foo } 1; my $foo = Foo->new; $foo->foo; # die my $bar = Bar->new; $bar->bar; # ok
Attributes
Private
When the Private traits is applied to an attribute, this attribute can only be read or set within the class.
Protected
When the Protected traits is applied to an attribute, this attribute can only be read or set within the class AND any of his subclasses.
AUTHOR
franck cuny <franck@lumberjaph.net>
COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by franck cuny.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Module Install Instructions
To install MooseX::Privacy, copy and paste the appropriate command in to your terminal.
cpanm MooseX::Privacy
perl -MCPAN -e shell install MooseX::Privacy
For more information on module installation, please visit the detailed CPAN module installation guide.