Open djerius opened 2 years ago
The way MooX::Press gets a reference to has
is:
# I hate this...
$_cached_moo_helper{"$package\::$helpername"} ||= eval sprintf(
'do { package %s; use Moo%s; my $coderef = \&%s; no Moo%s; $coderef };',
$package,
$is_role ? '::Role' : '',
$helpername,
$is_role ? '::Role' : '',
);
So yes, it will get a "fresh" copy of has
, and not the one you've wrapped.
Not sure what a good solution for this is.
Perhaps something like:
$_cached_moo_helper{"$package\::$helpername"} ||=
do { no strict 'refs'; \&{"$package\::$helpername"} } ||
eval sprintf(
'do { package %s; use Moo%s; my $coderef = \&%s; no Moo%s; $coderef };',
$package,
$is_role ? '::Role' : '',
$helpername,
$is_role ? '::Role' : '',
);
That works for my case, but unfortunately it breaks tests:
t/91factoryroles-zylite.t ..... Dubious, test returned 255 (wstat 65280, 0xff00)
No subtests run
t/91factoryroles.t ............ Undefined subroutine &MyApp::with called at /tmp/MooX-Press-0.086/lib/MooX/Press.pm line 1842.
BEGIN failed--compilation aborted at t/91factoryroles.t line 21.
t/91factoryroles.t ............ Dubious, test returned 255 (wstat 65280, 0xff00)
No subtests run
I'd like to apply a role to a
MooX::Press
generated class which modifieshas
. Here's the role:And here's the
Moo::Xpress
class:Here's a test class which is equivalent to the above generated one:
And here's what I get when I load the classes:
I'm guessing it's not finding the modified version of
has
.