From a2613e7ae5c3c9e8e78d8617a6669b723c2f5dd3 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Wed, 10 Feb 2010 14:09:40 +0100 Subject: meta class, with private and protected roles --- lib/MooseX/Privacy/Meta/Class/Protected.pm | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/MooseX/Privacy/Meta/Class/Protected.pm (limited to 'lib/MooseX/Privacy/Meta/Class/Protected.pm') diff --git a/lib/MooseX/Privacy/Meta/Class/Protected.pm b/lib/MooseX/Privacy/Meta/Class/Protected.pm new file mode 100644 index 0000000..b9d6314 --- /dev/null +++ b/lib/MooseX/Privacy/Meta/Class/Protected.pm @@ -0,0 +1,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; + -- cgit 1.4.1