
MooseX::MethodPrivate - Declare methods private or protected

package Foo;
use MooseX::MethodPrivate;
private 'foo' => sub {
...
}
protected 'bar' => sub {
...
}
...
my $foo = Foo->new;
$foo->foo; # die, can't call foo because it's a private method
$foo->bar; # die, can't call bar because it's a protected method
package Bar;
use MooseX::MethodPrivate;
extends qw/Foo/;
sub baz {
my $self = shift;
$self->foo; #Â die, can't call foo because it's a private method
$self->bar; # ok, can call this method because we extends Foo and
# it's a protected method
}

MooseX::MethodPrivate add two new keyword for methods declaration:
A private method is visible only in the class.
A protected method is visible in the class and any subclasses.

franck cuny <franck.cuny {at} rtgi.fr>

Idea stolen from Moose::Cookbook::Meta::Recipe6.

Copyright (c) 2009, RTGI All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.