On Wed, Oct 12, 2011 at 11:28:38AM -0400, Laurent Dami via RT wrote:
Show quoted text> Anyway, meanwhile the problem remains, and this is really annoying, so
> if you don't like the patch, please do something to find another
> solution.
>
> I just got stuck with the same problem in DBIx::DataModel (which uses
> namespace::autoclean, overload, but no Moose).
I've encountered similar issues when memoizing methods in a Moose class.
This is the wrapper I wrote for it (i.e. add the new methods in the MOP)...
sub memoize_with_normalizer($$)
{
my ($full_method_name, $normalizer) = @_;
my $sub = memoize($full_method_name, NORMALIZER => $normalizer);
# install the memoized sub into the correct class, so Test::CleanNamespaces
# doesn't complain about this as an uncleaned import.
my ($package, $method_name) = ($full_method_name =~ /^(.*)::([^:]+)$/);
my $mutable = $package->meta->is_immutable;
$package->meta->make_mutable if $mutable;
$package->meta->add_method($method_name => $sub);
$package->meta->make_immutable if $mutable;
}
I think it would probably be sane to add some interfaces to add overloads
that added the methods to the MOP.