问候,
作为我之前关于 Moose 的问题的后续,我现在遇到了一个新问题。我有一个 Moose 类,它使用配方 12来扩展非 Moose 父类。这里是:
package MyApp::CGI;
### TODO: make this work with MooseX::Declare?
use Moose;
extends 'CGI::Application';
sub new {
my $class = shift;
my $obj = $class->SUPER::new( @_ );
return $class->meta->new_object( __INSTANCE__ => $obj, @_ );
}
sub setup {
my $self = shift;
$self->start_mode( 'main' );
my @methods = map { $_->name } $self->meta->get_all_methods;
$self->run_modes( map { /^rm_(.+)$/ => $_ }
grep { /^rm_/ }
@methods
);
}
这很好用。我也有这个类的一个子类,它使用MooseX::Declare
. 但是,因为我现在覆盖了默认的 Moose 构造函数,所以我的子类会发出以下警告:
Not inlining 'new' for MyApp::CGI::Login since it is not inheriting the default Moose::Object::new
If you are certain you don't need to inline your constructor, specify inline_constructor => 0 in your call to MyApp::CGI::Login->meta->make_immutable
由于在幕后自动MooseX::Declare
调用make_immutable
,我一直无法弄清楚如何让它打开inline_constructor => 0
参数。