My apologies if this has already been addressed, but should roles respond to
"DOES"?
{
package Some::Role;
use Moose::Role;
}
{
package Some::Other::Role;
use Moose::Role;
with 'Some::Role';
}
{
package Some::Class;
use Moose;
with 'Some::Other::Role';
}
print Some::Class->DOES('Some::Role'); # good
print Some::Other::Role->DOES('Some::Role'); # bad
print Some::Role->DOES('Some::Role'); # bad
That prints out:
Can't locate object method "DOES" via package "Some::Other::Role" at
role.pl
line 18.
1
shell returned 255
The use case here is that when roles are composed from other roles, I might
want
to query a role directly as to whether or not it does a given role. Further, I
was thinking that all roles should response true for $role->DOES($role).
I know I can write those as this:
print Some::Class->meta->does_role('Some::Role');
print Some::Other::Role->meta->does_role('Some::Role');
print Some::Role->meta->does_role('Some::Role');
But the inconsistency in ->DOES seems odd and I was wondering if this is
desired
behavior.
This is Moose 1.21.
Cheers,
Ovid--
Live and work overseas - http://overseas-exile.blogspot.com/
Buy the book - http://www.oreilly.com/catalog/perlhks/
Tech blog - http://blogs.perl.org/users/ovid/
Twitter - http://twitter.com/OvidPerl/