When using MooseX::Declare and MooseX::MethodAttributes in the same package I get error when getting the method attributes using:
$attrs = $class->meta->get_method('moosey')->attributes;
I get the error:
Can't locate object method "attributes" via package "MooseX::Method::Signatures::Meta::Method"
I tried to look at the code for the module MooseX::MethodAttributes
and I was able to get
these methods to work about 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;
The issue here is the module uses a numeric pointer to the attributes which I do not know how to generate to get specific method attributes.
If I run this code:
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);
I get this debug information:
$VAR1 = [
70862136
];
$VAR1 = {
'70862136' => [
'AttrMoosey',
'AttrBoosy(path/app)',
'AttrCoosy'
]
};
So how can I get the method attributes in this case until these modules are fixed to work with each other properly.
Here is the code I use for testing:
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);
As stated in this answer, MooseX::MethodAttributes would need to be fixed to respect the original method metaclass, rather than imposing one.