summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-02-10 14:11:38 +0100
committerfranck cuny <franck@lumberjaph.net>2010-02-10 14:11:38 +0100
commit983f7f81b63f0435c221298683e7a0f3d987292d (patch)
tree6bd1cbaedef6e37b9fd8c428bfbe5f88d366f7d3
parentgenerate private and protected methods (diff)
downloadmoosex-privacy-983f7f81b63f0435c221298683e7a0f3d987292d.tar.gz
export private and protected
-rw-r--r--lib/MooseX/Privacy.pm39
1 files changed, 36 insertions, 3 deletions
diff --git a/lib/MooseX/Privacy.pm b/lib/MooseX/Privacy.pm
index aba8c14..4794a14 100644
--- a/lib/MooseX/Privacy.pm
+++ b/lib/MooseX/Privacy.pm
@@ -1,20 +1,53 @@
 package MooseX::Privacy;
 
-use strict;
-use warnings;
 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 -
+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