Skip Menu |

This queue is for tickets about the MooX-Enumeration CPAN distribution.

Report information
The Basics
Id: 128285
Status: resolved
Priority: 0/
Queue: MooX-Enumeration

People
Owner: Nobody in particular
Requestors: djerius [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.007
Fixed in: (no value)



Subject: Doesn't work in Moo Roles
MooX::Enumeration: 0.007 Moo::Role: 2.003004 Unfortunately, there's a problem using MooX::Enumeration in Moo Roles: package Foo; use Moo::Role; use MooX::Enumeration; has status => ( is => 'ro', isa => Enum [qw[ pass fail ]], handles => 1, ); 1; with the result perl Foo.pm Foo doesn't have a `has` function at Foo.pm line 5. BEGIN failed--compilation aborted at Foo.pm line 5. Thanks, Diab
I think I know how to fix this. Would it be possible for you to write a Test::More-based test case for this, with a role, a class that consumes the role, and some tests to check the class works as expected?
On Fri Jan 18 06:37:24 2019, TOBYINK wrote: Show quoted text
> I think I know how to fix this. > > Would it be possible for you to write a Test::More-based test case for > this, with a role, a class that consumes the role, and some tests to > check the class works as expected?
Will do.
On Fri Jan 18 11:04:48 2019, DJERIUS wrote: Show quoted text
> On Fri Jan 18 06:37:24 2019, TOBYINK wrote:
> > I think I know how to fix this. > > > > Would it be possible for you to write a Test::More-based test case for > > this, with a role, a class that consumes the role, and some tests to > > check the class works as expected?
> > > Will do.
Which do you prefer, github or bitbucket? I'm fine with either.
Either really. I use Mercurial locally, but with the hg-git plugin for pushing/pulling to/from github.
On Sat Jan 19 09:55:19 2019, TOBYINK wrote: Show quoted text
> Either really. I use Mercurial locally, but with the hg-git plugin for > pushing/pulling to/from github.
Sorry for the delay. I've put up two versions of the added test; one which tests role composition and errors during import of MooX::Enumeration, https://bitbucket.org/djerius/p5-moox-enumeration/src/test_import+with/ and one which just tests that the role composition works. https://bitbucket.org/djerius/p5-moox-enumeration/src/test_with/ Diab
Should mostly work in roles now, but because the subs are built when the role is built (and not when the role is composed into the class) the subs have zero knowledge of the class, so it won't work for edge cases like non-hashref objects. In future versions, I might be able to improve it by making the subs call a reader/accessor instead of direct slot access when they detect they're being built for a role, but that's future Toby's problem.
On Sun Nov 10 19:56:06 2019, TOBYINK wrote: Show quoted text
> Should mostly work in roles now, but because the subs are built when > the role is built (and not when the role is composed into the class) > the subs have zero knowledge of the class, so it won't work for edge > cases like non-hashref objects. > > In future versions, I might be able to improve it by making the subs > call a reader/accessor instead of direct slot access when they detect > they're being built for a role, but that's future Toby's problem.
Thanks!