{{$NEXT}}
+ [ENHANCEMENTS]
+
+ * Moose::Util::does_role now respects overridden ->does methods. (doy)
+
2.0104-TRIAL Mon, Jun 20, 2011
[OTHER]
use List::Util qw(first);
use List::MoreUtils qw(any all);
use overload ();
+use Try::Tiny;
use Class::MOP;
my @exports = qw[
sub does_role {
my ($class_or_obj, $role) = @_;
+ if (try { $class_or_obj->can('does') }) {
+ return $class_or_obj->does($role);
+ }
+
my $meta = find_meta($class_or_obj);
return unless defined $meta;
with 'Foo';
}
+{
+ package DoesMethod;
+ use Moose;
+
+ sub does {
+ my $self = shift;
+ my ($role) = @_;
+ return 1 if $role eq 'Something::Else';
+ return $self->SUPER::does(@_);
+ }
+}
+
# Classes
ok(does_role('Bar', 'Foo'), '... Bar does Foo');
ok(!does_role('Quux', 'Foo'), '... Quux doesnt do Foo (does not die tho)');
+# overriding the does method works properly
+
+ok(does_role('DoesMethod', 'Something::Else'), '... can override the does method');
+
# TODO: make the below work, maybe?
# Self