[perl][MooseX::MethodAttributes]
Catalystの中身が変わってたのでなかを眺めてたら
get_nearest_methods_with_attributes
ってのがあって
The same as get_all_methods_with_attributes, except that methods from parent classes are not included if there is an attributeless method in a child class.
nearestってなんだと思ったらこういうことか。
http://search.cpan.org/perldoc?MooseX::MethodAttributes::Role::Meta::Class
とりあえず、動かしてみてもみた。
1 package BaseClass; 2 use Moose; 3 use MooseX::MethodAttributes; 4 5 sub foo : Attr { } 6 sub bar : Attr { } 7 8 package SubClass; 9 use Moose; 10 extends 'BaseClass'; 11 12 sub foo {} 13 14 after bar => sub {}; 15 16 package main; 17 use Data::Dumper; 18 19 for my $method ( qw/ 20 get_method_with_attributes_list 21 get_all_methods_with_attributes 22 get_nearest_methods_with_attributes 23 /) { 24 warn $method . "\n"; 25 for my $hoge ( SubClass->meta->$method ) { 26 warn $hoge->name . "\n"; 27 } 28 }
結果
get_method_with_attributes_list get_all_methods_with_attributes foo bar get_nearest_methods_with_attributes bar