summary refs log tree commit diff
path: root/lib/MooseX/Privacy/Meta/Class/Protected.pm
blob: b9d6314b3a723205f82e3806e0fbf4348e6d51cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package MooseX::Privacy::Meta::Class::Protected;

use Moose::Role;
use MooseX::Types::Moose qw(Str ArrayRef );
use MooseX::Privacy::Meta::Method::Protected;

has local_protected_methods => (
    traits     => ['Array'],
    is         => 'ro',
    isa        => ArrayRef [Str],
    required   => 1,
    default    => sub { [] },
    auto_deref => 1,
    handles    => { 'push_protected_method' => 'push' },
);

sub add_protected_method {
    my ( $self, $method_name, $code ) = @_;
    $self->add_method(
        $method_name,
        MooseX::Privacy::Meta::Method::Protected->new(
            name         => $method_name,
            body         => $code,
            package_name => $self->name
        )
    );
    $self->push_protected_method($method_name);
}

1;