From: gfx Date: Fri, 26 Feb 2010 09:24:11 +0000 (+0900) Subject: Make does_role accept a role meta object X-Git-Tag: 0.50_04~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f3e1112299b631f1ab6150159eaa414dca37a42c;p=gitmo%2FMouse.git Make does_role accept a role meta object --- diff --git a/lib/Mouse/Meta/Class.pm b/lib/Mouse/Meta/Class.pm index 7a9dd8b..276b16d 100644 --- a/lib/Mouse/Meta/Class.pm +++ b/lib/Mouse/Meta/Class.pm @@ -96,7 +96,7 @@ sub _reconcile_with_superclass_meta { my @roles; foreach my $role($super_meta->meta->calculate_all_roles){ - if(!$self->meta->does_role($role->name)){ + if(!$self->meta->does_role($role)){ push @roles, $role->name; } } @@ -439,6 +439,8 @@ sub does_role { (defined $role_name) || $self->throw_error("You must supply a role name to look for"); + $role_name = $role_name->name if ref $role_name; + for my $class ($self->linearized_isa) { my $meta = Mouse::Util::get_metaclass_by_name($class) or next; diff --git a/lib/Mouse/Meta/Role.pm b/lib/Mouse/Meta/Role.pm index a41d5a6..c030b70 100644 --- a/lib/Mouse/Meta/Role.pm +++ b/lib/Mouse/Meta/Role.pm @@ -170,7 +170,7 @@ sub _append_roles{ my $roles = $consumer->{roles}; foreach my $r($role, @{$role->get_roles}){ - if(!$consumer->does_role($r->name)){ + if(!$consumer->does_role($r)){ push @{$roles}, $r; } } @@ -288,6 +288,8 @@ sub does_role { (defined $role_name) || $self->throw_error("You must supply a role name to look for"); + $role_name = $role_name->name if ref $role_name; + # if we are it,.. then return true return 1 if $role_name eq $self->name; # otherwise.. check our children