Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Moose::Meta::Class needs a package?

by Boldra (Deacon)
on Jul 11, 2011 at 06:43 UTC ( #913657=perlquestion: print w/ replies, xml ) Need Help??
Boldra has asked for the wisdom of the Perl Monks concerning the following question:

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

Comment on Moose::Meta::Class needs a package?
Select or Download Code
Re: Moose::Meta::Class needs a package?
by stvn (Monsignor) on Jul 11, 2011 at 23:56 UTC
    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:

    You want Moose::Object, not Moose.

    -stvn
      Thankyou! That is much cleaner now.


      - Boldra

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://913657]
Approved by davido
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2014-08-20 22:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (124 votes), past polls