Changes to date added for wu-lee.
[gitmo/Mouse.git] / lib / Mouse / Meta / Class.pm
index f4a94e4..9e6ef57 100644 (file)
@@ -156,6 +156,10 @@ sub compute_all_applicable_attributes {
 sub get_attribute_map { $_[0]->{attributes} }
 sub has_attribute     { exists $_[0]->{attributes}->{$_[1]} }
 sub get_attribute     { $_[0]->{attributes}->{$_[1]} }
+sub get_attribute_list {
+    my $self = shift;
+    keys %{$self->get_attribute_map};
+}
 
 sub linearized_isa { @{ get_linear_isa($_[0]->name) } }
 
@@ -291,8 +295,11 @@ sub does_role {
     (defined $role_name)
         || confess "You must supply a role name to look for";
 
-    for my $role (@{ $self->{roles} }) {
-        return 1 if $role->name eq $role_name;
+    for my $class ($self->linearized_isa) {
+        next unless $class->can('meta') and $class->meta->can('roles');
+        for my $role (@{ $self->roles }) {
+            return 1 if $role->name eq $role_name;
+        }
     }
 
     return 0;
@@ -415,6 +422,12 @@ this class and its superclasses.
 Returns a mapping of attribute names to their corresponding
 L<Mouse::Meta::Attribute> objects.
 
+=head2 get_attribute_list -> { name => Mouse::Meta::Attribute }
+
+This returns a list of attribute names which are defined in the local
+class. If you want a list of all applicable attributes for a class,
+use the C<compute_all_applicable_attributes> method.
+
 =head2 has_attribute Name -> Bool
 
 Returns whether we have a L<Mouse::Meta::Attribute> with the given name.