return class_of( $_[0] );
}
-sub does_role{
+sub _does_role_impl {
my ($class_or_obj, $role_name) = @_;
my $meta = class_of($class_or_obj);
return defined($meta) && $meta->does_role($role_name);
}
+sub does_role {
+ my($thing, $role_name) = @_;
+
+ if( (Scalar::Util::blessed($thing) || is_class_loaded($thing))
+ && $thing->can('does')) {
+ return $thing->does($role_name);
+ }
+ goto &_does_role_impl;
+}
+
# taken from Mouse::Util (0.90)
{
my %cache;
# general does() method
sub does :method {
- goto &does_role;
+ goto &_does_role_impl;
}
1;