From: Fuji, Goro Date: Mon, 21 Feb 2011 01:45:12 +0000 (+0900) Subject: Support DOES() X-Git-Tag: 0.90~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d8ac424a86a0d9703f3e0502c8935b4851bf29af;p=gitmo%2FMouse.git Support DOES() --- diff --git a/lib/Mouse/Object.pm b/lib/Mouse/Object.pm index 73184d1..9975c65 100644 --- a/lib/Mouse/Object.pm +++ b/lib/Mouse/Object.pm @@ -1,6 +1,12 @@ package Mouse::Object; use Mouse::Util qw(does dump meta); # enables strict and warnings # all the stuff are defined in XS or PP + +sub DOES { + my($self, $class_or_role_name) = @_; + return $self->isa($class_or_role_name) || $self->does($class_or_role_name); +} + 1; __END__ diff --git a/t/000_recipes/moose_cookbook_roles_recipe1.t b/t/000_recipes/moose_cookbook_roles_recipe1.t index 16f6775..c11d186 100644 --- a/t/000_recipes/moose_cookbook_roles_recipe1.t +++ b/t/000_recipes/moose_cookbook_roles_recipe1.t @@ -85,11 +85,8 @@ ok( US::Currency->does('Printable'), '... US::Currency does Printable' ); my $hundred = US::Currency->new( amount => 100.00 ); isa_ok( $hundred, 'US::Currency' ); -{ -local $TODO = 'UNIVERSAL::DOES is not supported'; -ok( eval{ $hundred->DOES("US::Currency") }, "UNIVERSAL::DOES for class" ); -ok( eval{ $hundred->DOES("Comparable") }, "UNIVERSAL::DOES for role" ); -} +ok( $hundred->DOES("US::Currency"), "UNIVERSAL::DOES for class" ); +ok( $hundred->DOES("Comparable"), "UNIVERSAL::DOES for role" ); can_ok( $hundred, 'amount' ); is( $hundred->amount, 100, '... got the right amount' );