From: Shawn M Moore Date: Sat, 29 Nov 2008 01:28:48 +0000 (+0000) Subject: Class::MOP::Method->execute X-Git-Tag: 0.71_01~33 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=25a5f083d2d06a7823822e3a0c66baad3377d75b;p=gitmo%2FClass-MOP.git Class::MOP::Method->execute --- diff --git a/Changes b/Changes index 13da349..efd899f 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,10 @@ Revision history for Perl extension Class-MOP. +0.72 + * Class::MOP::Method + - Add an "execute" method to invoke the body so + we can avoid using the coderef overload (Sartak) + 0.71 Wed November 26, 2008 * Class::MOP::Class * Class::MOP::Module diff --git a/lib/Class/MOP/Method.pm b/lib/Class/MOP/Method.pm index 0665bd2..4581498 100644 --- a/lib/Class/MOP/Method.pm +++ b/lib/Class/MOP/Method.pm @@ -121,6 +121,11 @@ sub original_fully_qualified_name { : $self->fully_qualified_name; } +sub execute { + my $self = shift; + $self->body->(@_); +} + # NOTE: # the Class::MOP bootstrap # will create this for us @@ -246,6 +251,17 @@ Disassociates the method from the metaclass =back +=head2 Miscellaneous + +=over 4 + +=item B + +Executes the method. Be sure to pass in the instance, since the +method expects it. + +=back + =head1 AUTHORS Stevan Little Estevan@iinteractive.comE diff --git a/t/003_methods.t b/t/003_methods.t index d21e7be..f178034 100644 --- a/t/003_methods.t +++ b/t/003_methods.t @@ -10,7 +10,7 @@ use Scalar::Util qw/reftype/; BEGIN { if ( eval 'use Sub::Name (); 1;' ) { - plan tests => 65; + plan tests => 66; } else { plan skip_all => 'These tests require Sub::Name'; @@ -94,6 +94,7 @@ is($foo_method->package_name, 'Foo', '... got the right package name for the met ok($Foo->has_method('foo'), '... Foo->has_method(foo) (defined with Sub::Name)'); is($Foo->get_method('foo')->body, $foo, '... Foo->get_method(foo) == \&foo'); +is($Foo->get_method('foo')->execute, 'Foo::foo', '... _method_foo->execute returns "Foo::foo"'); is(Foo->foo(), 'Foo::foo', '... Foo->foo() returns "Foo::foo"'); # now check all our other items ...