我有一個附加驗證的文件名屬性。現在當在構造過程中未指定文件名時,我想從配置文件中讀取它。Moose:將參數注入到構造中
subtype 'filename'
=> as 'Str'
=> where { -r $_ }
=> message { "$_ is not a readable file" };
has 'students_file' => (is => 'rw', isa => 'filename', default => '');
has 'teachers_file' => (is => 'rw', isa => 'filename', default => '');
問題是BUILD
似乎在驗證發生後運行。 BUILDARGS
的所有示例似乎都處理構建對象的不同方式。
那麼我應該在哪裏閱讀配置並設置屬性?