2 package Moose::Meta::Role;
8 use Scalar::Util 'blessed';
10 use Devel::GlobalDestruction 'in_global_destruction';
12 use Moose::Meta::Class;
13 use Moose::Meta::Role::Attribute;
14 use Moose::Meta::Role::Method;
15 use Moose::Meta::Role::Method::Required;
16 use Moose::Meta::Role::Method::Conflicting;
17 use Moose::Meta::Method::Meta;
18 use Moose::Util qw( ensure_all_roles );
19 use Class::MOP::MiniTrait;
21 use base 'Class::MOP::Module',
22 'Class::MOP::Mixin::HasAttributes',
23 'Class::MOP::Mixin::HasMethods';
25 Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait');
27 ## ------------------------------------------------------------------
29 ## I normally don't do this, but I am doing
30 ## a whole bunch of meta-programmin in this
31 ## module, so it just makes sense. For a clearer
32 ## picture of what is going on in the next
33 ## several lines of code, look at the really
34 ## big comment at the end of this file (right
37 ## ------------------------------------------------------------------
39 my $META = __PACKAGE__->meta;
41 ## ------------------------------------------------------------------
45 # since roles are lazy, we hold all the attributes
46 # of the individual role in 'statis' until which
47 # time when it is applied to a class. This means
48 # keeping a lot of things in hash maps, so we are
49 # using a little of that meta-programmin' magic
50 # here an saving lots of extra typin. And since
51 # many of these attributes above require similar
52 # functionality to support them, so we again use
53 # the wonders of meta-programmin' to deliver a
54 # very compact solution to this normally verbose
60 name => 'excluded_roles_map',
61 attr_reader => 'get_excluded_roles_map' ,
63 add => 'add_excluded_roles',
64 get_keys => 'get_excluded_roles_list',
65 existence => 'excludes_role',
69 name => 'required_methods',
70 attr_reader => 'get_required_methods_map',
72 remove => 'remove_required_methods',
73 get_values => 'get_required_method_list',
74 existence => 'requires_method',
79 my $attr_reader = $action->{attr_reader};
80 my $methods = $action->{methods};
82 # create the attribute
83 $META->add_attribute($action->{name} => (
84 reader => $attr_reader,
85 default => sub { {} },
86 Class::MOP::_definition_context(),
89 # create some helper methods
90 $META->add_method($methods->{add} => sub {
91 my ($self, @values) = @_;
92 $self->$attr_reader->{$_} = undef foreach @values;
93 }) if exists $methods->{add};
95 $META->add_method($methods->{get_keys} => sub {
97 keys %{$self->$attr_reader};
98 }) if exists $methods->{get_keys};
100 $META->add_method($methods->{get_values} => sub {
102 values %{$self->$attr_reader};
103 }) if exists $methods->{get_values};
105 $META->add_method($methods->{get} => sub {
106 my ($self, $name) = @_;
107 $self->$attr_reader->{$name}
108 }) if exists $methods->{get};
110 $META->add_method($methods->{existence} => sub {
111 my ($self, $name) = @_;
112 exists $self->$attr_reader->{$name} ? 1 : 0;
113 }) if exists $methods->{existence};
115 $META->add_method($methods->{remove} => sub {
116 my ($self, @values) = @_;
117 delete $self->$attr_reader->{$_} foreach @values;
118 }) if exists $methods->{remove};
121 $META->add_attribute(
123 reader => 'method_metaclass',
124 default => 'Moose::Meta::Role::Method',
125 Class::MOP::_definition_context(),
128 $META->add_attribute(
129 'required_method_metaclass',
130 reader => 'required_method_metaclass',
131 default => 'Moose::Meta::Role::Method::Required',
132 Class::MOP::_definition_context(),
135 $META->add_attribute(
136 'conflicting_method_metaclass',
137 reader => 'conflicting_method_metaclass',
138 default => 'Moose::Meta::Role::Method::Conflicting',
139 Class::MOP::_definition_context(),
142 $META->add_attribute(
143 'application_to_class_class',
144 reader => 'application_to_class_class',
145 default => 'Moose::Meta::Role::Application::ToClass',
146 Class::MOP::_definition_context(),
149 $META->add_attribute(
150 'application_to_role_class',
151 reader => 'application_to_role_class',
152 default => 'Moose::Meta::Role::Application::ToRole',
153 Class::MOP::_definition_context(),
156 $META->add_attribute(
157 'application_to_instance_class',
158 reader => 'application_to_instance_class',
159 default => 'Moose::Meta::Role::Application::ToInstance',
160 Class::MOP::_definition_context(),
163 $META->add_attribute(
164 'applied_attribute_metaclass',
165 reader => 'applied_attribute_metaclass',
166 default => 'Moose::Meta::Attribute',
167 Class::MOP::_definition_context(),
170 # More or less copied from Moose::Meta::Class
174 unshift @args, 'package' if @args % 2;
176 my $package = delete $opts{package};
177 return Class::MOP::get_metaclass_by_name($package)
178 || $class->SUPER::initialize($package,
179 'attribute_metaclass' => 'Moose::Meta::Role::Attribute',
188 my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg);
190 my %existing_classes;
192 %existing_classes = map { $_ => $meta->$_() } qw(
195 wrapped_method_metaclass
196 required_method_metaclass
197 conflicting_method_metaclass
198 application_to_class_class
199 application_to_role_class
200 application_to_instance_class
201 applied_attribute_metaclass
206 $options{weaken} = Class::MOP::metaclass_is_weak($meta->name)
207 if !exists $options{weaken}
209 && $meta->isa('Moose::Meta::Role');
211 # don't need to remove generated metaobjects here yet, since we don't
212 # yet generate anything in roles. this may change in the future though...
213 # keep an eye on that
214 my $new_meta = $self->SUPER::reinitialize(
219 $new_meta->_restore_metaobjects_from($meta)
220 if $meta && $meta->isa('Moose::Meta::Role');
224 sub _restore_metaobjects_from {
228 $self->_restore_metamethods_from($old_meta);
229 $self->_restore_metaattributes_from($old_meta);
231 for my $role ( @{ $old_meta->get_roles } ) {
232 $self->add_role($role);
239 if (blessed $_[0] && ! $_[0]->isa('Moose::Meta::Role::Attribute') ) {
240 my $class = ref $_[0];
241 Moose->throw_error( "Cannot add a $class as an attribute to a role" );
243 elsif (!blessed($_[0]) && defined($_[0]) && $_[0] =~ /^\+(.*)/) {
244 Moose->throw_error( "has '+attr' is not supported in roles" );
247 return $self->SUPER::add_attribute(@_);
250 sub _attach_attribute {
251 my ( $self, $attribute ) = @_;
253 $attribute->attach_to_role($self);
256 sub add_required_methods {
261 if (!blessed($method)) {
262 $method = $self->required_method_metaclass->new(
266 $self->get_required_methods_map->{$method->name} = $method;
270 sub add_conflicting_method {
274 if (@_ == 1 && blessed($_[0])) {
278 $method = $self->conflicting_method_metaclass->new(@_);
281 $self->add_required_methods($method);
284 ## ------------------------------------------------------------------
288 # the before/around/after method modifiers are
289 # stored by name, but there can be many methods
290 # then associated with that name. So again we have
291 # lots of similar functionality, so we can do some
292 # meta-programmin' and save some time.
295 foreach my $modifier_type (qw[ before around after ]) {
297 my $attr_reader = "get_${modifier_type}_method_modifiers_map";
299 # create the attribute ...
300 $META->add_attribute("${modifier_type}_method_modifiers" => (
301 reader => $attr_reader,
302 default => sub { {} },
303 Class::MOP::_definition_context(),
306 # and some helper methods ...
307 $META->add_method("get_${modifier_type}_method_modifiers" => sub {
308 my ($self, $method_name) = @_;
309 #return () unless exists $self->$attr_reader->{$method_name};
310 my $mm = $self->$attr_reader->{$method_name};
314 $META->add_method("has_${modifier_type}_method_modifiers" => sub {
315 my ($self, $method_name) = @_;
317 # for now we assume that if it exists,..
318 # it has at least one modifier in it
319 (exists $self->$attr_reader->{$method_name}) ? 1 : 0;
322 $META->add_method("add_${modifier_type}_method_modifier" => sub {
323 my ($self, $method_name, $method) = @_;
325 $self->$attr_reader->{$method_name} = []
326 unless exists $self->$attr_reader->{$method_name};
328 my $modifiers = $self->$attr_reader->{$method_name};
331 # check to see that we aren't adding the
332 # same code twice. We err in favor of the
333 # first on here, this may not be as expected
334 foreach my $modifier (@{$modifiers}) {
335 return if $modifier == $method;
338 push @{$modifiers} => $method;
343 ## ------------------------------------------------------------------
344 ## override method mofidiers
346 $META->add_attribute('override_method_modifiers' => (
347 reader => 'get_override_method_modifiers_map',
348 default => sub { {} },
349 Class::MOP::_definition_context(),
353 # these are a little different because there
354 # can only be one per name, whereas the other
355 # method modifiers can have multiples.
358 sub add_override_method_modifier {
359 my ($self, $method_name, $method) = @_;
360 (!$self->has_method($method_name))
361 || Moose->throw_error("Cannot add an override of method '$method_name' " .
362 "because there is a local version of '$method_name'");
363 $self->get_override_method_modifiers_map->{$method_name} = $method;
366 sub has_override_method_modifier {
367 my ($self, $method_name) = @_;
369 # for now we assume that if it exists,..
370 # it has at least one modifier in it
371 (exists $self->get_override_method_modifiers_map->{$method_name}) ? 1 : 0;
374 sub get_override_method_modifier {
375 my ($self, $method_name) = @_;
376 $self->get_override_method_modifiers_map->{$method_name};
379 ## general list accessor ...
381 sub get_method_modifier_list {
382 my ($self, $modifier_type) = @_;
383 my $accessor = "get_${modifier_type}_method_modifiers_map";
384 keys %{$self->$accessor};
387 sub _meta_method_class { 'Moose::Meta::Method::Meta' }
389 ## ------------------------------------------------------------------
392 $META->add_attribute('roles' => (
393 reader => 'get_roles',
394 default => sub { [] },
395 Class::MOP::_definition_context(),
399 my ($self, $role) = @_;
400 (blessed($role) && $role->isa('Moose::Meta::Role'))
401 || Moose->throw_error("Roles must be instances of Moose::Meta::Role");
402 push @{$self->get_roles} => $role;
403 $self->reset_package_cache_flag;
406 sub calculate_all_roles {
412 $_->calculate_all_roles
413 } @{ $self->get_roles });
417 my ($self, $role) = @_;
419 || Moose->throw_error("You must supply a role name to look for");
420 my $role_name = blessed $role ? $role->name : $role;
421 # if we are it,.. then return true
422 return 1 if $role_name eq $self->name;
423 # otherwise.. check our children
424 foreach my $role (@{$self->get_roles}) {
425 return 1 if $role->does_role($role_name);
430 sub find_method_by_name { (shift)->get_method(@_) }
432 ## ------------------------------------------------------------------
434 ## ------------------------------------------------------------------
437 my ($self, $other, %args) = @_;
440 || Moose->throw_error("You must pass in an blessed instance");
442 my $application_class;
443 if ($other->isa('Moose::Meta::Role')) {
444 $application_class = $self->application_to_role_class;
446 elsif ($other->isa('Moose::Meta::Class')) {
447 $application_class = $self->application_to_class_class;
450 $application_class = $self->application_to_instance_class;
453 Class::MOP::load_class($application_class);
455 my $deprecation_check = 0;
457 if ( exists $args{excludes} && !exists $args{'-excludes'} ) {
458 $args{'-excludes'} = delete $args{excludes};
459 $deprecation_check = 1;
461 if ( exists $args{alias} && !exists $args{'-alias'} ) {
462 $args{'-alias'} = delete $args{alias};
463 $deprecation_check = 1;
466 if ( $deprecation_check ) {
467 Moose::Deprecated::deprecated(
468 feature => 'alias or excludes',
470 'The alias and excludes options for role application'.
471 ' have been renamed -alias and -excludes'.
472 " (${\$other->name} is consuming ${\$self->name}".
473 " - do you need to upgrade ${\$other->name}?).".
474 ' This will be an error in Moose 2.0200.'
478 if ( exists $args{'-excludes'} ) {
479 # I wish we had coercion here :)
480 $args{'-excludes'} = (
481 ref $args{'-excludes'} eq 'ARRAY'
483 : [ $args{'-excludes'} ]
487 return $application_class->new(%args)->apply($self, $other, \%args);
490 sub composition_class_roles { }
493 my ($class, @role_specs) = @_;
495 require Moose::Meta::Role::Composite;
497 my (@roles, %role_params);
498 while (@role_specs) {
499 my ($role, $params) = @{ splice @role_specs, 0, 1 };
503 : Class::MOP::class_of($role);
505 my $actual_role = $requested_role->_role_for_combination($params);
506 push @roles => $actual_role;
508 next unless defined $params;
509 $role_params{$actual_role->name} = $params;
512 my $c = Moose::Meta::Role::Composite->new(roles => \@roles);
513 return $c->apply_params(\%role_params);
516 sub _role_for_combination {
517 my ($self, $params) = @_;
525 unshift @args, 'package' if @args % 2 == 1;
528 (ref $options{attributes} eq 'HASH')
529 || confess "You must pass a HASH ref of attributes"
530 if exists $options{attributes};
532 (ref $options{methods} eq 'HASH')
533 || confess "You must pass a HASH ref of methods"
534 if exists $options{methods};
536 (ref $options{roles} eq 'ARRAY')
537 || confess "You must pass an ARRAY ref of roles"
538 if exists $options{roles};
540 my $package = delete $options{package};
541 my $roles = delete $options{roles};
542 my $attributes = delete $options{attributes};
543 my $methods = delete $options{methods};
544 my $meta_name = exists $options{meta_name}
545 ? delete $options{meta_name}
548 my $meta = $class->SUPER::create($package => %options);
550 $meta->_add_meta_method($meta_name)
551 if defined $meta_name;
553 if (defined $attributes) {
554 foreach my $attribute_name (keys %{$attributes}) {
555 my $attr = $attributes->{$attribute_name};
556 $meta->add_attribute(
557 $attribute_name => blessed $attr ? $attr : %{$attr} );
561 if (defined $methods) {
562 foreach my $method_name (keys %{$methods}) {
563 $meta->add_method($method_name, $methods->{$method_name});
568 Moose::Util::apply_all_roles($meta, @$roles);
577 for my $meta (Class::MOP::get_all_metaclass_instances) {
578 next if $meta->name eq $self->name;
579 next unless $meta->isa('Moose::Meta::Class')
580 || $meta->isa('Moose::Meta::Role');
581 push @consumers, $meta->name
582 if $meta->does_role($self->name);
587 # XXX: something more intelligent here?
588 sub _anon_package_prefix { 'Moose::Meta::Role::__ANON__::SERIAL::' }
590 sub create_anon_role { shift->create_anon(@_) }
591 sub is_anon_role { shift->is_anon(@_) }
593 sub _anon_cache_key {
597 # XXX fix this duplication (see MMC::_anon_cache_key
598 my $roles = Data::OptList::mkopt(($options{roles} || []), {
600 val_test => sub { ref($_[0]) eq 'HASH' },
604 for my $role_spec (@$roles) {
605 my ($role, $params) = @$role_spec;
606 $params = { %$params };
608 my $key = blessed($role) ? $role->name : $role;
610 if ($params && %$params) {
611 my $alias = delete $params->{'-alias'}
612 || delete $params->{'alias'}
614 my $excludes = delete $params->{'-excludes'}
615 || delete $params->{'excludes'}
617 $excludes = [$excludes] unless ref($excludes) eq 'ARRAY';
620 warn "Roles with parameters cannot be cached. Consider "
621 . "applying the parameters before calling "
622 . "create_anon_class, or using 'weaken => 0' instead";
626 my $alias_key = join('%',
627 map { $_ => $alias->{$_} } sort keys %$alias
629 my $excludes_key = join('%',
632 $key .= '<' . join('+', 'a', $alias_key, 'e', $excludes_key) . '>';
635 push @role_keys, $key;
638 # Makes something like Role|Role::1
639 return join('|', sort @role_keys);
642 #####################################################################
644 ## This is Moose::Meta::Role as defined by Moose (plus the use of
645 ## MooseX::AttributeHelpers module). It is here as a reference to
646 ## make it easier to see what is happening above with all the meta
648 #####################################################################
651 # metaclass => 'Array',
652 # reader => 'get_roles',
653 # isa => 'ArrayRef[Moose::Meta::Role]',
654 # default => sub { [] },
656 # 'push' => 'add_role',
660 # has 'excluded_roles_map' => (
661 # metaclass => 'Hash',
662 # reader => 'get_excluded_roles_map',
663 # isa => 'HashRef[Str]',
665 # # Not exactly set, cause it sets multiple
666 # 'set' => 'add_excluded_roles',
667 # 'keys' => 'get_excluded_roles_list',
668 # 'exists' => 'excludes_role',
672 # has 'required_methods' => (
673 # metaclass => 'Hash',
674 # reader => 'get_required_methods_map',
675 # isa => 'HashRef[Moose::Meta::Role::Method::Required]',
677 # # not exactly set, or delete since it works for multiple
678 # 'set' => 'add_required_methods',
679 # 'delete' => 'remove_required_methods',
680 # 'keys' => 'get_required_method_list',
681 # 'exists' => 'requires_method',
685 # # the before, around and after modifiers are
686 # # HASH keyed by method-name, with ARRAY of
687 # # CODE refs to apply in that order
689 # has 'before_method_modifiers' => (
690 # metaclass => 'Hash',
691 # reader => 'get_before_method_modifiers_map',
692 # isa => 'HashRef[ArrayRef[CodeRef]]',
694 # 'keys' => 'get_before_method_modifiers',
695 # 'exists' => 'has_before_method_modifiers',
696 # # This actually makes sure there is an
697 # # ARRAY at the given key, and pushed onto
698 # # it. It also checks for duplicates as well
699 # # 'add' => 'add_before_method_modifier'
703 # has 'after_method_modifiers' => (
704 # metaclass => 'Hash',
705 # reader =>'get_after_method_modifiers_map',
706 # isa => 'HashRef[ArrayRef[CodeRef]]',
708 # 'keys' => 'get_after_method_modifiers',
709 # 'exists' => 'has_after_method_modifiers',
710 # # This actually makes sure there is an
711 # # ARRAY at the given key, and pushed onto
712 # # it. It also checks for duplicates as well
713 # # 'add' => 'add_after_method_modifier'
717 # has 'around_method_modifiers' => (
718 # metaclass => 'Hash',
719 # reader =>'get_around_method_modifiers_map',
720 # isa => 'HashRef[ArrayRef[CodeRef]]',
722 # 'keys' => 'get_around_method_modifiers',
723 # 'exists' => 'has_around_method_modifiers',
724 # # This actually makes sure there is an
725 # # ARRAY at the given key, and pushed onto
726 # # it. It also checks for duplicates as well
727 # # 'add' => 'add_around_method_modifier'
731 # # override is similar to the other modifiers
732 # # except that it is not an ARRAY of code refs
733 # # but instead just a single name->code mapping
735 # has 'override_method_modifiers' => (
736 # metaclass => 'Hash',
737 # reader =>'get_override_method_modifiers_map',
738 # isa => 'HashRef[CodeRef]',
740 # 'keys' => 'get_override_method_modifier',
741 # 'exists' => 'has_override_method_modifier',
742 # 'add' => 'add_override_method_modifier', # checks for local method ..
746 #####################################################################
751 # ABSTRACT: The Moose Role metaclass
759 This class is a subclass of L<Class::MOP::Module> that provides
760 additional Moose-specific functionality.
762 Its API looks a lot like L<Moose::Meta::Class>, but internally it
763 implements many things differently. This may change in the future.
767 C<Moose::Meta::Role> is a subclass of L<Class::MOP::Module>.
775 =item B<< Moose::Meta::Role->initialize($role_name) >>
777 This method creates a new role object with the provided name.
779 =item B<< Moose::Meta::Role->combine( [ $role => { ... } ], [ $role ], ... ) >>
781 This method accepts a list of array references. Each array reference
782 should contain a role name or L<Moose::Meta::Role> object as its first element. The second element is
783 an optional hash reference. The hash reference can contain C<-excludes>
784 and C<-alias> keys to control how methods are composed from the role.
786 The return value is a new L<Moose::Meta::Role::Composite> that
787 represents the combined roles.
789 =item B<< $metarole->composition_class_roles >>
791 When combining multiple roles using C<combine>, this method is used to obtain a
792 list of role names to be applied to the L<Moose::Meta::Role::Composite>
793 instance returned by C<combine>. The default implementation returns an empty
794 list. Extensions that need to hook into role combination may wrap this method
795 to return additional role names.
797 =item B<< Moose::Meta::Role->create($name, %options) >>
799 This method is identical to the L<Moose::Meta::Class> C<create>
802 =item B<< Moose::Meta::Role->create_anon_role >>
804 This method is identical to the L<Moose::Meta::Class>
805 C<create_anon_class> method.
807 =item B<< $metarole->is_anon_role >>
809 Returns true if the role is an anonymous role.
811 =item B<< $metarole->consumers >>
813 Returns a list of names of classes and roles which consume this role.
817 =head2 Role application
821 =item B<< $metarole->apply( $thing, @options ) >>
823 This method applies a role to the given C<$thing>. That can be another
824 L<Moose::Meta::Role>, object, a L<Moose::Meta::Class> object, or a
825 (non-meta) object instance.
827 The options are passed directly to the constructor for the appropriate
828 L<Moose::Meta::Role::Application> subclass.
830 Note that this will apply the role even if the C<$thing> in question already
831 C<does> this role. L<Moose::Util/does_role> is a convenient wrapper for
832 finding out if role application is necessary.
836 =head2 Roles and other roles
840 =item B<< $metarole->get_roles >>
842 This returns an array reference of roles which this role does. This
843 list may include duplicates.
845 =item B<< $metarole->calculate_all_roles >>
847 This returns a I<unique> list of all roles that this role does, and
848 all the roles that its roles do.
850 =item B<< $metarole->does_role($role) >>
852 Given a role I<name> or L<Moose::Meta::Role> object, returns true if this role
855 =item B<< $metarole->add_role($role) >>
857 Given a L<Moose::Meta::Role> object, this adds the role to the list of
858 roles that the role does.
860 =item B<< $metarole->get_excluded_roles_list >>
862 Returns a list of role names which this role excludes.
864 =item B<< $metarole->excludes_role($role_name) >>
866 Given a role I<name>, returns true if this role excludes the named
869 =item B<< $metarole->add_excluded_roles(@role_names) >>
871 Given one or more role names, adds those roles to the list of excluded
878 The methods for dealing with a role's methods are all identical in API
879 and behavior to the same methods in L<Class::MOP::Class>.
883 =item B<< $metarole->method_metaclass >>
885 Returns the method metaclass name for the role. This defaults to
886 L<Moose::Meta::Role::Method>.
888 =item B<< $metarole->get_method($name) >>
890 =item B<< $metarole->has_method($name) >>
892 =item B<< $metarole->add_method( $name, $body ) >>
894 =item B<< $metarole->get_method_list >>
896 =item B<< $metarole->find_method_by_name($name) >>
898 These methods are all identical to the methods of the same name in
899 L<Class::MOP::Package>
905 As with methods, the methods for dealing with a role's attribute are
906 all identical in API and behavior to the same methods in
907 L<Class::MOP::Class>.
909 However, attributes stored in this class are I<not> stored as
910 objects. Rather, the attribute definition is stored as a hash
911 reference. When a role is composed into a class, this hash reference
912 is passed directly to the metaclass's C<add_attribute> method.
914 This is quite likely to change in the future.
918 =item B<< $metarole->get_attribute($attribute_name) >>
920 =item B<< $metarole->has_attribute($attribute_name) >>
922 =item B<< $metarole->get_attribute_list >>
924 =item B<< $metarole->add_attribute($name, %options) >>
926 =item B<< $metarole->remove_attribute($attribute_name) >>
930 =head2 Required methods
934 =item B<< $metarole->get_required_method_list >>
936 Returns the list of methods required by the role.
938 =item B<< $metarole->requires_method($name) >>
940 Returns true if the role requires the named method.
942 =item B<< $metarole->add_required_methods(@names) >>
944 Adds the named methods to the role's list of required methods.
946 =item B<< $metarole->remove_required_methods(@names) >>
948 Removes the named methods from the role's list of required methods.
950 =item B<< $metarole->add_conflicting_method(%params) >>
952 Instantiate the parameters as a L<Moose::Meta::Role::Method::Conflicting>
953 object, then add it to the required method list.
957 =head2 Method modifiers
959 These methods act like their counterparts in L<Class::MOP::Class> and
960 L<Moose::Meta::Class>.
962 However, method modifiers are simply stored internally, and are not
963 applied until the role itself is applied to a class.
967 =item B<< $metarole->add_after_method_modifier($method_name, $method) >>
969 =item B<< $metarole->add_around_method_modifier($method_name, $method) >>
971 =item B<< $metarole->add_before_method_modifier($method_name, $method) >>
973 =item B<< $metarole->add_override_method_modifier($method_name, $method) >>
975 These methods all add an appropriate modifier to the internal list of
978 =item B<< $metarole->has_after_method_modifiers >>
980 =item B<< $metarole->has_around_method_modifiers >>
982 =item B<< $metarole->has_before_method_modifiers >>
984 =item B<< $metarole->has_override_method_modifier >>
986 Return true if the role has any modifiers of the given type.
988 =item B<< $metarole->get_after_method_modifiers($method_name) >>
990 =item B<< $metarole->get_around_method_modifiers($method_name) >>
992 =item B<< $metarole->get_before_method_modifiers($method_name) >>
994 Given a method name, returns a list of the appropriate modifiers for
997 =item B<< $metarole->get_override_method_modifier($method_name) >>
999 Given a method name, returns the override method modifier for that
1000 method, if it has one.
1004 =head2 Introspection
1008 =item B<< Moose::Meta::Role->meta >>
1010 This will return a L<Class::MOP::Class> instance for this class.
1016 See L<Moose/BUGS> for details on reporting bugs.