summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-02-10 14:09:40 +0100
committerfranck cuny <franck@lumberjaph.net>2010-02-10 14:09:40 +0100
commita2613e7ae5c3c9e8e78d8617a6669b723c2f5dd3 (patch)
treedbdb325d13c67c320db32af4b08a044b9c675b2d
parentinitial commit (diff)
downloadmoosex-privacy-a2613e7ae5c3c9e8e78d8617a6669b723c2f5dd3.tar.gz
meta class, with private and protected roles
-rw-r--r--lib/MooseX/Privacy/Meta/Class/Private.pm30
-rw-r--r--lib/MooseX/Privacy/Meta/Class/Protected.pm31
2 files changed, 61 insertions, 0 deletions
diff --git a/lib/MooseX/Privacy/Meta/Class/Private.pm b/lib/MooseX/Privacy/Meta/Class/Private.pm
new file mode 100644
index 0000000..a6e7546
--- /dev/null
+++ b/lib/MooseX/Privacy/Meta/Class/Private.pm
@@ -0,0 +1,30 @@
+package MooseX::Privacy::Meta::Class::Private;
+
+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, $code ) = @_;
+    $self->add_method(
+        $method_name,
+        MooseX::Privacy::Meta::Method::Private->new(
+            name         => $method_name,
+            body         => $code,
+            package_name => $self->name
+        )
+    );
+    $self->push_private_method($method_name);
+}
+
+1;
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;
+