If build object subroutine works with another Object-Lazy, $AUTOLOAD is changed and the also
requested method is changed. To fix this simply store locally $AUTOLOAD value before calling
the build subroutine and after that use stored value. Patch attached.
Subject: | object-lazy.patch |
--- Lazy.pm 2012-08-18 22:21:07.000000000 +0200
+++ /usr/local/share/perl/5.10.1/Object/Lazy.pm 2012-09-18 14:19:33.000000000 +0200
@@ -47,8 +47,11 @@
sub AUTOLOAD { ## no critic (Autoloading ArgUnpacking)
my ($self, @params) = @_;
+ our $AUTOLOAD;
+ my $orig_autoload = $AUTOLOAD;
+
my $built_object = $build_object->($self, \$_[0]);
- my $method = substr our $AUTOLOAD, 2 + length __PACKAGE__;
+ my $method = substr $orig_autoload, 2 + length __PACKAGE__;
return $built_object->$method(@params);
}