From: gfx Date: Sat, 24 Oct 2009 04:25:43 +0000 (+0900) Subject: Rename ::Meta::Method::new to ::Meta::Method::wrap to fit to Moose X-Git-Tag: 0.40_01~39 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=commitdiff_plain;h=9010458d614641c8103b1d06b479e0c80aa1dcda Rename ::Meta::Method::new to ::Meta::Method::wrap to fit to Moose --- diff --git a/lib/Mouse/Meta/Method.pm b/lib/Mouse/Meta/Method.pm index 458dbbb..f800ff0 100755 --- a/lib/Mouse/Meta/Method.pm +++ b/lib/Mouse/Meta/Method.pm @@ -6,15 +6,24 @@ use overload fallback => 1, ; -sub new{ - my($class, %args) = @_; +sub wrap{ + my $class = shift; - return bless \%args, $class; + return $class->_new(@_); } -sub body { $_[0]->{body} } -sub name { $_[0]->{name} } -sub package_name{ $_[0]->{package} } +sub _new{ + my $class = shift; + return $class->meta->new_object(@_) + if $class ne __PACKAGE__; + + return bless {@_}, $class; +} + +sub body { $_[0]->{body} } +sub name { $_[0]->{name} } +sub package_name { $_[0]->{package} } +sub associated_metaclass { $_[0]->{associated_metaclass} } sub fully_qualified_name { my $self = shift; @@ -22,7 +31,6 @@ sub fully_qualified_name { } 1; - __END__ =head1 NAME diff --git a/lib/Mouse/Meta/Module.pm b/lib/Mouse/Meta/Module.pm index 227313e..690e7c7 100755 --- a/lib/Mouse/Meta/Module.pm +++ b/lib/Mouse/Meta/Module.pm @@ -150,10 +150,11 @@ sub get_method{ load_class($method_metaclass); my $package = $self->name; - return $method_metaclass->new( - body => $package->can($method_name), - name => $method_name, - package => $package, + return $method_metaclass->wrap( + body => $package->can($method_name), + name => $method_name, + package => $package, + associated_metaclass => $self, ); } diff --git a/lib/Mouse/Meta/Role/Method.pm b/lib/Mouse/Meta/Role/Method.pm index e86f9a1..1279bce 100755 --- a/lib/Mouse/Meta/Role/Method.pm +++ b/lib/Mouse/Meta/Role/Method.pm @@ -4,6 +4,13 @@ use Mouse::Util; # enables strict and warnings use Mouse::Meta::Method; our @ISA = qw(Mouse::Meta::Method); +sub _new { + my $class = shift; + return $class->meta->new_object(@_) + if $class ne __PACKAGE__; + return bless {@_}, $class; +} + 1; __END__