summaryrefslogtreecommitdiff
path: root/lib/MooseX/Privacy.pm
blob: 4794a14f3536fc5bd25c307abc223c5854cb6c18 (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
package MooseX::Privacy;

our $VERSION = '0.01';

use Moose::Exporter;

Moose::Exporter->setup_import_methods(
    with_caller => [qw( private protected )], );

sub private {
    my ( $caller, $name, $body ) = @_;
    $caller->meta->add_private_method( $name, $body );
}

sub protected {
    my ( $caller, $name, $body ) = @_;
    $caller->meta->add_protected_method( $name, $body );
}

sub init_meta {
    my ( $me, %options ) = @_;

    my $for = $options{for_class};
    Moose->init_meta(%options);

    Moose::Util::MetaRole::apply_metaclass_roles(
        for_class       => $for,
        metaclass_roles => [ 'MooseX::Privacy::Meta::Class', ],
    );
}

1;
__END__

=head1 NAME

MooseX::Privacy - Provides syntax to enable privacy on your methods

=head1 SYNOPSIS

  use MooseX::Privacy;

  private foo => sub {
    return 23;
  };

  protect bar => sub {
    return 42;
  };

=head1 DESCRIPTION

MooseX::Privacy is

=head1 AUTHOR

franck cuny E<lt>franck.cuny@rtgi.frE<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