Subject: | Moose::Meta::Class add_methid only works once |
I'm using add_method() on a Moose::Meta::Class to dynamically add a
method. I have attached a simple test case to demonstrate this (it uses
Test::More).
Using Moose version 0.79 and Class::MOP version 0.84 the attached test
works.
Using Moose version 0.89, Class::MOP version 0.92, it does not.
Subject: | test_sub.t |
#!/opt/perl-5.8.8/bin/perl
Test::go();
package Test;
use Moose;
use Moose::Meta::Class;
use Class::MOP;
use Test::More tests => 3;
sub go {
#print "Moose version = " . $Moose::VERSION . "\n";
#print "Moose::Meta::Class = ". $Moose::Meta::Class::VERSION . "\n";
#print "Class::MOP = ". $Class::MOP::VERSION . "\n";
foreach my $name_space ('a', 'b', 'c') {
my $provider = Moose::Meta::Class->create($name_space);
my $sub = sub {
my ($self, $c, $message) = @_;
my $response = { status => 'PONG' };
$c->stash->{response} = $response;
};
my $p = $provider->add_method('ping', $sub);
my $method = $provider->get_method('ping');
ok($method, "Got my ping method back!");
}
}