From 1ae3b8b58a365a3db69c7a705cda9b90f822b524 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Sun, 14 Feb 2010 14:19:43 +0100 Subject: add_{private,protected}_method accept meta method --- lib/MooseX/Privacy/Meta/Class/Private.pm | 12 ++++++++++-- lib/MooseX/Privacy/Meta/Class/Protected.pm | 13 +++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'lib/MooseX') 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; + -- cgit 1.4.1