NAME

MooseX::MethodPrivate - Declare methods private or protected

SYNOPSIS

    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
    }

DESCRIPTION

MooseX::MethodPrivate add two new keyword for methods declaration:

private
protected

METHODS

private

A private method is visible only in the class.

protected

A protected method is visible in the class and any subclasses.

AUTHOR

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

SEE ALSO

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

LICENSE

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.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 77:

Non-ASCII character seen before =encoding in '# die,'. Assuming UTF-8