Problem with mixins in class MooseX :: NonMoose

Consider the following:

package MyApp::CGI;

use Moose;
use MooseX::NonMoose;
use Data::Dumper;

extends 'CGI::Application';

BEGIN { 
    print "begin isa = " . Dumper \@MyApp::CGI::ISA;
};

print "runtime isa = " . Dumper \@MyApp::CGI::ISA;

... 

Conclusion when this compiles:

begin isa = $VAR1 = [
          'Moose::Object'
        ];
runtime isa = $VAR1 = [
          'CGI::Application',
          'Moose::Object'
        ];

Why does it bother me? Because when I try to useuse the CGI :: Application :: Plugin :: * class, it expects me to inherit from CGI::Applicationalready at compile time. The plugin class is trying to call add_callbackas a class method in my class, but cannot, because mine @ISAis not configured yet.

What is the best way to solve this problem? Will @ISAmanual configuration in the block BEGINinterfere MooseX::NonMoose?

Edit

Work appears, but I find it offensive:

package MyApp::CGI;

use Moose;
use MooseX::NonMoose;

use base 'CGI::Application';
extends 'CGI::Application';

I don't know enough (or anything, really) about Moose's insides to find out if this is a good idea.

+5
1

use base 'CGI::Application'; extends 'CGI::Application'; , , :

  • @ISA 'CGI::Application', CGI:: Application:: Plugin:: *
  • Moose CGI:: , ( -). , extends 'CGI::Application', - (.. ), , extends: Moose::Object, - .

, jrockway :

BEGIN { extends 'CGI::Application' }

..., - , , , , use Moose use MooseX::NonMoose extends.

(: , , , BEGIN. - , Moose.pm use compiletime qw(extends). .)

+5

All Articles