ご挨拶、
Moose に関する以前の質問の補足として、新しい問題に遭遇しました。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
。ただし、デフォルトの 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