in reply to Moops: meta not available in role

Hi Oberon,

I have not really used Moops; however, it appears that Moops uses Moo by default. The Moops documentation states Moops uses Moo to build classes and roles by default, but allows you to use Moose if you desire. (And Mouse experimentally.).

According to the INCOMPATIBILITIES_WITH_MOOSE section of the Moo documentation, Moo does not have a meta object.

So in order to get the meta object you need to tell Moops to use Moose. See the Roles section of the Moops documentation.

Adding using Moose to your code fixes the issue.

use v5.14.4; use warnings; use autodie qw< :all >; use Moops; role Foo using Moose { use Data::Printer; p __PACKAGE__->meta; } 1;

Replies are listed 'Best First'.
Re^2: Moops: meta not available in role
by Oberon (Monk) on Jul 28, 2015 at 23:18 UTC
    According to the INCOMPATIBILITIES_WITH_MOOSE section of the Moo documentation, Moo does not have a meta object.

    AHA! I had totally forgotten that about Moo. That is exactly the issue. (And I totally should have known that by the fact that I was calling a Moose::Util method ...)

    Adding using Moose to your code fixes the issue.

    Well, yes, but what I really wanted was a way to do what I was trying to do in Moo. But, now that I look at it more closely, I don't believe Moo supports traits at all ... not even in any sort of MooX module. Possibly Moo is unable to do attribute traits due the lack of a MOP. So I guess do need to take your suggestion and just tell Moops to use Moose everywhere. (To wit, I think I'll use MoopsX::UsingMoose.)

    So here's some code which works:

    use MoopsX::UsingMoose; use autodie qw< :all >; role Foo { use Data::Printer; p __PACKAGE__->meta; }

    Note that, after more careful reading of the Moops docs, I figured out that I don't need the use v5.14 line, nor the use warnings line, nor even the 1; at the end of the module: Moops itself will do all that for me. Cool.

    Thx for the assist, kevbot.

      I figured out that I don't need the use v5.14 line, nor the use warnings line, nor even the 1; at the end of the module: Moops itself will do all that for me.

      FYI if you are writing a module for CPAN distribution, you will be penalized in kwalitee if you omit use warnings; or use strict; from your code, even if you are using Moo(se|ps). Not sure about the other "features."

      The way forward always starts with a minimal test.

        FYI if you are writing a module for CPAN distribution, you will be penalized in kwalitee if you omit use warnings; or use strict; from your code, even if you are using Moo(se|ps). Not sure about the other "features."

        So you found a bug in some "kwalitee" module/service?