5
作爲後續約駝鹿我previous question,我現在遇到了新的問題。我有一個Moose類,它使用Recipe 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
。但是,因爲我現在覆蓋默認的構造函數駝鹿,我的子類發出這樣的警告:
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
參數。