2 package Mouse::Meta::Role;
9 # because Mouse doesn't introspect existing classes, we're forced to
10 # only pay attention to other Mouse classes
11 sub _metaclass_cache {
14 return $METACLASS_CACHE{$name};
20 $METACLASS_CACHE{$name} = $class->new(name => $name)
21 if !exists($METACLASS_CACHE{$name});
22 return $METACLASS_CACHE{$name};
30 $args{attributes} ||= {};
35 sub name { $_[0]->{name} }
41 $self->{attributes}->{$name} = $spec;
44 sub has_attribute { exists $_[0]->{attributes}->{$_[1]} }
45 sub get_attribute_list { keys %{ $_[0]->{attributes} } }
46 sub get_attribute { $_[0]->{attributes}->{$_[1]} }
51 my $pkg = $class->name;
53 for my $name ($self->get_attribute_list) {
54 next if $class->has_attribute($name);
55 my $spec = $self->get_attribute($name);
56 Mouse::Meta::Attribute->create($pkg, $name, %$spec);