1
當使用同一個包MooseX::Declare和MooseX::MethodAttributes我得到錯誤獲取方法使用屬性時:的Perl MooseX :: MethodAttributes get方法屬性
$attrs = $class->meta->get_method('moosey')->attributes;
我得到的錯誤:
Can't locate object method "attributes" via package "MooseX::Method::Signatures::Meta::Method"
我試圖看看模塊MooseX::MethodAttributes
的代碼,並且我能夠獲得 這些方法來處理屬性:
my $attribute_list = $class->meta->get_method('moosey')->associated_metaclass()->_method_attribute_list;
my $attribute_map = $class->meta->get_method('moosey')->associated_metaclass()->_method_attribute_map;
這裏的問題是模塊使用數字指針指向屬性,我不知道如何生成以獲取特定的方法屬性。
如果我運行此代碼:
my $attribute_list = $class->meta->get_method('moosey')->associated_metaclass()->_method_attribute_list;
my $attribute_map = $class->meta->get_method('moosey')->associated_metaclass()->_method_attribute_map;
print Dumper($attribute_list);
print Dumper($attribute_map);
我得到這個調試信息:
$VAR1 = [
70862136
];
$VAR1 = {
'70862136' => [
'AttrMoosey',
'AttrBoosy(path/app)',
'AttrCoosy'
]
};
所以,我怎麼能得到的方法在這種情況下屬性,直到這些模塊固定在一起工作其他適當。
這裏是我用於測試的代碼:
package Moosey;
use Moose;
use MooseX::Declare;
use MooseX::MethodAttributes;
class Moosey is mutable {
method moosey ($name, $email) : AttrMoosey AttrBoosy(path/app) AttrCoosy { print "moosey called"; }
}
1;
use Data::Dumper;
my $class = Moosey->new;
my $method = $class->meta->get_method('moosey');
# this does not work:
# my $attrs = $class->meta->get_method('moosey')->attributes;
my $attribute_list = $class->meta->get_method('moosey')->associated_metaclass()->_method_attribute_list;
my $attribute_map = $class->meta->get_method('moosey')->associated_metaclass()->_method_attribute_map;
print Dumper($attribute_list);
print Dumper($attribute_map);
我看到你是cpan模塊'MooseX :: MethodAttributes'的作者[https://metacpan.org/pod/MooseX::MethodAttributes](https://metacpan.org/pod/MooseX :: MethodAttributes),是否有計劃很快發佈此修復程序? – daliaessam