blob: e706e67b89c4469c4c5efa535ed85e87955ef35a (
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
|
package MooseX::Privacy::Meta::Method::Private;
use Moose;
extends 'Moose::Meta::Method';
use Carp qw/confess/;
sub wrap {
my $class = shift;
my %args = @_;
my $method = delete $args{body};
my $private_code = sub {
confess "The "
. $args{package_name} . "::"
. $args{name}
. " method is private"
unless ( scalar caller() ) eq $args{package_name};
goto &{$method};
};
$args{body} = $private_code;
$class->SUPER::wrap(%args);
}
1;
__END__
=head1 NAME
MooseX::Privacy::Meta::Method::Private
=head1 SYNOPSIS
=head1 METHODS
=head2 wrap
=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
|