blob: d63757cdcabffd7165514a7aeae808bcd6e65eb3 (
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
|
package MooseX::Privacy::Meta::Class::Private;
use Scalar::Util;
use Carp qw/confess/;
use Moose::Role;
use MooseX::Types::Moose qw/Str ArrayRef/;
use MooseX::Privacy::Meta::Method::Private;
has local_private_methods => (
traits => ['Array'],
is => 'ro',
isa => ArrayRef [Str],
required => 1,
default => sub { [] },
auto_deref => 1,
handles => { '_push_private_method' => 'push' },
);
sub add_private_method {
my ( $self, $method_name, $method ) = @_;
my $private_method
= blessed $method
? $method
: MooseX::Privacy::Meta::Method::Private->wrap(
name => $method_name,
package_name => $self->name,
body => $method
);
confess 'not a private method'
unless $private_method->isa('MooseX::Privacy::Meta::Method::Private');
$self->add_method( $private_method->name, $private_method );
$self->_push_private_method( $private_method->name );
}
1;
__END__
=head1 NAME
MooseX::Privacy::Meta::Class::Private
=head1 SYNOPSIS
=head1 METHODS
=head2 local_private_methods
=head2 add_private_method
=head1 AUTHOR
franck cuny E<lt>franck@lumberjaph.netE<gt>
=head1 SEE ALSO
=head1 LICENSE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
|