Subject: | Broken can() |
The can() implementation currently just returns 1. According to the
UNIVERSAL documentation this is wrong as the can method should return a
code reference to the method that would be invoked if you would have
invoked a method with the name given as the second argument.
The following code, which could be taken as a testcase, is ought to work:
my $o = Hash::AsObject->new({ a => 42 });
die unless $o->can('a')->($o) == 42;
but it currently doesn't as perl will try to dereference a plan scalar
holding '1', which is not going to work. It'll throw an exception instead.
A possible solution is to generate the accessor/mutator methods in can
as well as in AUTOLOAD and return a reference to the newly created sub
from can.
If you want me to I can provide a fix and tests for this issue.