summaryrefslogtreecommitdiff
path: root/lib/MooseX/Privacy/Meta/Class.pm
blob: b286a7e4163c52763cfb7bd41a137e6170b8da56 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package MooseX::Privacy::Meta::Class;

#ABSTRACT: Meta Class for your privacy

use Moose::Role;
use Moose::Meta::Class;

with(
    'MooseX::Privacy::Meta::Class::Role' => { name => 'protected' },
    'MooseX::Privacy::Meta::Class::Role' => { name => 'private' },
);

package Moose::Meta::Attribute::Custom::Trait::Private;
sub register_implementation {'MooseX::Privacy::Trait::Private'}

package Moose::Meta::Attribute::Custom::Trait::Protected;
sub register_implementation {'MooseX::Privacy::Trait::Protected'}

1;

__END__

=head1 METHODS

=head2 local_private_attributes

Arrayref of all private attributes

    my $private_attributes = $self->meta->local_private_attributes;

=head2 local_private_methods

Arrayref of all private methods

    my $private_methods = $self->meta->local_private_methods;

=head2 add_private_method

Add a private method to your object.

    $object->meta->add_private_method('foo', sub { return 23 });

or

    $object->meta->add_private_method(
        'foo',
        MooseX::Privacy::Meta::Method::Private->wrap(
            name         => 'foo',
            package_name => 'Foo',
            body         => sub { return 23 }
        )
    );

=head2 local_protected_attributes

Arrayref of all protected attributes

    my $protected_attributes = $self->meta->local_protected_attributes;

=head2 local_protected_methods

Arrayref of all protected methods

    my $private_methods = $self->meta->local_protected_methods;

=head2 add_protected_method

Add a protected method to your object.

    $object->meta->add_protected_method('foo', sub { return 23 });

or

    $object->meta->add_protected_method(
        'foo',
        MooseX::Privacy::Meta::Method::Protected->wrap(
            name         => 'foo',
            package_name => 'Foo',
            body         => sub { return 23 }
        )
    );