summary refs log tree commit diff
path: root/lib/MooseX/Privacy/Meta/Class
diff options
context:
space:
mode:
Diffstat (limited to 'lib/MooseX/Privacy/Meta/Class')
-rw-r--r--lib/MooseX/Privacy/Meta/Class/Private.pm12
-rw-r--r--lib/MooseX/Privacy/Meta/Class/Protected.pm13
2 files changed, 21 insertions, 4 deletions
diff --git a/lib/MooseX/Privacy/Meta/Class/Private.pm b/lib/MooseX/Privacy/Meta/Class/Private.pm
index 7cea57c..0482d08 100644
--- a/lib/MooseX/Privacy/Meta/Class/Private.pm
+++ b/lib/MooseX/Privacy/Meta/Class/Private.pm
@@ -15,12 +15,20 @@ has local_private_methods => (
 );
 
 sub add_private_method {
-    my ( $self, $method_name, $code ) = @_;
+    my $self = shift;
+    my ( $method_name, $body );
+    if ( scalar @_ == 1 ) {
+        $method_name = $_[0]->name;
+        $body        = $_[0]->body;
+    }
+    else {
+        ( $method_name, $body ) = @_;
+    }
     $self->add_method(
         $method_name,
         MooseX::Privacy::Meta::Method::Private->wrap(
             name         => $method_name,
-            body         => $code,
+            body         => $body,
             package_name => $self->name
         )
     );
diff --git a/lib/MooseX/Privacy/Meta/Class/Protected.pm b/lib/MooseX/Privacy/Meta/Class/Protected.pm
index aa5936e..3b80010 100644
--- a/lib/MooseX/Privacy/Meta/Class/Protected.pm
+++ b/lib/MooseX/Privacy/Meta/Class/Protected.pm
@@ -15,12 +15,20 @@ has local_protected_methods => (
 );
 
 sub add_protected_method {
-    my ( $self, $method_name, $code ) = @_;
+    my $self = shift;
+    my ( $method_name, $body );
+    if ( scalar @_ == 1 ) {
+        $method_name = $_[0]->name;
+        $body        = $_[0]->body;
+    }
+    else {
+        ($method_name, $body) = @_;
+    }
     $self->add_method(
         $method_name,
         MooseX::Privacy::Meta::Method::Protected->wrap(
             name         => $method_name,
-            body         => $code,
+            body         => $body,
             package_name => $self->name
         )
     );
@@ -29,3 +37,4 @@ sub add_protected_method {
 
 1;
 
+