I'm using Moose::Meta::Class directly to test a plugin interface.

Plugin interface:

sub load_plugin { my $class = "My::Plugin::$_[0]"; eval "use $class" return $class->new }
Any my tests share the _make_fake_plugin sub:
package Emtpy; use Moose; package main; sub _make_fake_plugin { my $class = "My::Plugin::$_[0]"; $INC{"My/Plugin/$_[0].pm"} = 1; Moose::Meta::Class->create( $class => ( methods => { run => sub { push @FAKE_PLUGIN_LOG, \@_ } }, superclasses => [ qw<Empty> ], roles => [ qw<My::Plugin> ], ), ); }
Naturally there's quite a few checks in load_plugin which I'm not showing (and the role). Those are what I'm actually testing.

What I'm really curious about, is the need for the Empty package. If I substitute the Empty for Moose directly I get the error:

Can't locate object method "class_precedence_list" via package "Class: +:MOP::Package"
I stole this syntax from the Moose::Meta::Class tests, (the doc is a bit thin) but I don't understand it. Can anyone explain why this is needed? Is there a cleaner way?

thanks


- Boldra

In reply to Moose::Meta::Class needs a package? by Boldra

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.