2 package Moose::Meta::Role;
8 use Scalar::Util 'blessed';
10 use Devel::GlobalDestruction 'in_global_destruction';
12 our $AUTHORITY = 'cpan:STEVAN';
14 use Moose::Meta::Class;
15 use Moose::Meta::Role::Attribute;
16 use Moose::Meta::Role::Method;
17 use Moose::Meta::Role::Method::Required;
18 use Moose::Meta::Role::Method::Conflicting;
19 use Moose::Meta::Method::Meta;
20 use Moose::Util qw( ensure_all_roles );
21 use Class::MOP::MiniTrait;
23 use base 'Class::MOP::Module',
24 'Class::MOP::Mixin::HasAttributes',
25 'Class::MOP::Mixin::HasMethods';
27 Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait');
29 ## ------------------------------------------------------------------
31 ## I normally don't do this, but I am doing
32 ## a whole bunch of meta-programmin in this
33 ## module, so it just makes sense. For a clearer
34 ## picture of what is going on in the next
35 ## several lines of code, look at the really
36 ## big comment at the end of this file (right
39 ## ------------------------------------------------------------------
41 my $META = __PACKAGE__->meta;
43 ## ------------------------------------------------------------------
47 # since roles are lazy, we hold all the attributes
48 # of the individual role in 'statis' until which
49 # time when it is applied to a class. This means
50 # keeping a lot of things in hash maps, so we are
51 # using a little of that meta-programmin' magic
52 # here an saving lots of extra typin. And since
53 # many of these attributes above require similar
54 # functionality to support them, so we again use
55 # the wonders of meta-programmin' to deliver a
56 # very compact solution to this normally verbose
62 name => 'excluded_roles_map',
63 attr_reader => 'get_excluded_roles_map' ,
65 add => 'add_excluded_roles',
66 get_keys => 'get_excluded_roles_list',
67 existence => 'excludes_role',
71 name => 'required_methods',
72 attr_reader => 'get_required_methods_map',
74 remove => 'remove_required_methods',
75 get_values => 'get_required_method_list',
76 existence => 'requires_method',
81 my $attr_reader = $action->{attr_reader};
82 my $methods = $action->{methods};
84 # create the attribute
85 $META->add_attribute($action->{name} => (
86 reader => $attr_reader,
90 # create some helper methods
91 $META->add_method($methods->{add} => sub {
92 my ($self, @values) = @_;
93 $self->$attr_reader->{$_} = undef foreach @values;
94 }) if exists $methods->{add};
96 $META->add_method($methods->{get_keys} => sub {
98 keys %{$self->$attr_reader};
99 }) if exists $methods->{get_keys};
101 $META->add_method($methods->{get_values} => sub {
103 values %{$self->$attr_reader};
104 }) if exists $methods->{get_values};
106 $META->add_method($methods->{get} => sub {
107 my ($self, $name) = @_;
108 $self->$attr_reader->{$name}
109 }) if exists $methods->{get};
111 $META->add_method($methods->{existence} => sub {
112 my ($self, $name) = @_;
113 exists $self->$attr_reader->{$name} ? 1 : 0;
114 }) if exists $methods->{existence};
116 $META->add_method($methods->{remove} => sub {
117 my ($self, @values) = @_;
118 delete $self->$attr_reader->{$_} foreach @values;
119 }) if exists $methods->{remove};
122 $META->add_attribute(
124 reader => 'method_metaclass',
125 default => 'Moose::Meta::Role::Method',
128 $META->add_attribute(
129 'required_method_metaclass',
130 reader => 'required_method_metaclass',
131 default => 'Moose::Meta::Role::Method::Required',
134 $META->add_attribute(
135 'conflicting_method_metaclass',
136 reader => 'conflicting_method_metaclass',
137 default => 'Moose::Meta::Role::Method::Conflicting',
140 $META->add_attribute(
141 'application_to_class_class',
142 reader => 'application_to_class_class',
143 default => 'Moose::Meta::Role::Application::ToClass',
146 $META->add_attribute(
147 'application_to_role_class',
148 reader => 'application_to_role_class',
149 default => 'Moose::Meta::Role::Application::ToRole',
152 $META->add_attribute(
153 'application_to_instance_class',
154 reader => 'application_to_instance_class',
155 default => 'Moose::Meta::Role::Application::ToInstance',
158 $META->add_attribute(
159 'applied_attribute_metaclass',
160 reader => 'applied_attribute_metaclass',
161 default => 'Moose::Meta::Attribute',
164 # More or less copied from Moose::Meta::Class
169 if (defined(my $meta = Class::MOP::get_metaclass_by_name($pkg))) {
175 my $meta = $class->SUPER::initialize(
177 'attribute_metaclass' => 'Moose::Meta::Role::Attribute',
181 Class::MOP::weaken_metaclass($pkg) if $options{weaken};
190 my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg);
192 my %existing_classes;
194 %existing_classes = map { $_ => $meta->$_() } qw(
197 wrapped_method_metaclass
198 required_method_metaclass
199 conflicting_method_metaclass
200 application_to_class_class
201 application_to_role_class
202 application_to_instance_class
203 applied_attribute_metaclass
208 $options{weaken} = Class::MOP::metaclass_is_weak($meta->name)
209 if !exists $options{weaken}
211 && $meta->isa('Moose::Meta::Role');
213 # don't need to remove generated metaobjects here yet, since we don't
214 # yet generate anything in roles. this may change in the future though...
215 # keep an eye on that
216 my $new_meta = $self->SUPER::reinitialize(
221 $new_meta->_restore_metaobjects_from($meta)
222 if $meta && $meta->isa('Moose::Meta::Role');
226 sub _restore_metaobjects_from {
230 $self->_restore_metamethods_from($old_meta);
231 $self->_restore_metaattributes_from($old_meta);
237 if (blessed $_[0] && ! $_[0]->isa('Moose::Meta::Role::Attribute') ) {
238 my $class = ref $_[0];
239 Moose->throw_error( "Cannot add a $class as an attribute to a role" );
241 elsif (!blessed($_[0]) && defined($_[0]) && $_[0] =~ /^\+(.*)/) {
242 Moose->throw_error( "has '+attr' is not supported in roles" );
245 return $self->SUPER::add_attribute(@_);
248 sub _attach_attribute {
249 my ( $self, $attribute ) = @_;
251 $attribute->attach_to_role($self);
254 sub add_required_methods {
259 if (!blessed($method)) {
260 $method = $self->required_method_metaclass->new(
264 $self->get_required_methods_map->{$method->name} = $method;
268 sub add_conflicting_method {
272 if (@_ == 1 && blessed($_[0])) {
276 $method = $self->conflicting_method_metaclass->new(@_);
279 $self->add_required_methods($method);
282 ## ------------------------------------------------------------------
286 # the before/around/after method modifiers are
287 # stored by name, but there can be many methods
288 # then associated with that name. So again we have
289 # lots of similar functionality, so we can do some
290 # meta-programmin' and save some time.
293 foreach my $modifier_type (qw[ before around after ]) {
295 my $attr_reader = "get_${modifier_type}_method_modifiers_map";
297 # create the attribute ...
298 $META->add_attribute("${modifier_type}_method_modifiers" => (
299 reader => $attr_reader,
300 default => sub { {} }
303 # and some helper methods ...
304 $META->add_method("get_${modifier_type}_method_modifiers" => sub {
305 my ($self, $method_name) = @_;
306 #return () unless exists $self->$attr_reader->{$method_name};
307 my $mm = $self->$attr_reader->{$method_name};
311 $META->add_method("has_${modifier_type}_method_modifiers" => sub {
312 my ($self, $method_name) = @_;
314 # for now we assume that if it exists,..
315 # it has at least one modifier in it
316 (exists $self->$attr_reader->{$method_name}) ? 1 : 0;
319 $META->add_method("add_${modifier_type}_method_modifier" => sub {
320 my ($self, $method_name, $method) = @_;
322 $self->$attr_reader->{$method_name} = []
323 unless exists $self->$attr_reader->{$method_name};
325 my $modifiers = $self->$attr_reader->{$method_name};
328 # check to see that we aren't adding the
329 # same code twice. We err in favor of the
330 # first on here, this may not be as expected
331 foreach my $modifier (@{$modifiers}) {
332 return if $modifier == $method;
335 push @{$modifiers} => $method;
340 ## ------------------------------------------------------------------
341 ## override method mofidiers
343 $META->add_attribute('override_method_modifiers' => (
344 reader => 'get_override_method_modifiers_map',
345 default => sub { {} }
349 # these are a little different because there
350 # can only be one per name, whereas the other
351 # method modifiers can have multiples.
354 sub add_override_method_modifier {
355 my ($self, $method_name, $method) = @_;
356 (!$self->has_method($method_name))
357 || Moose->throw_error("Cannot add an override of method '$method_name' " .
358 "because there is a local version of '$method_name'");
359 $self->get_override_method_modifiers_map->{$method_name} = $method;
362 sub has_override_method_modifier {
363 my ($self, $method_name) = @_;
365 # for now we assume that if it exists,..
366 # it has at least one modifier in it
367 (exists $self->get_override_method_modifiers_map->{$method_name}) ? 1 : 0;
370 sub get_override_method_modifier {
371 my ($self, $method_name) = @_;
372 $self->get_override_method_modifiers_map->{$method_name};
375 ## general list accessor ...
377 sub get_method_modifier_list {
378 my ($self, $modifier_type) = @_;
379 my $accessor = "get_${modifier_type}_method_modifiers_map";
380 keys %{$self->$accessor};
383 sub _meta_method_class { 'Moose::Meta::Method::Meta' }
385 ## ------------------------------------------------------------------
388 $META->add_attribute('roles' => (
389 reader => 'get_roles',
390 default => sub { [] }
394 my ($self, $role) = @_;
395 (blessed($role) && $role->isa('Moose::Meta::Role'))
396 || Moose->throw_error("Roles must be instances of Moose::Meta::Role");
397 push @{$self->get_roles} => $role;
398 $self->reset_package_cache_flag;
401 sub calculate_all_roles {
407 $_->calculate_all_roles
408 } @{ $self->get_roles });
412 my ($self, $role) = @_;
414 || Moose->throw_error("You must supply a role name to look for");
415 my $role_name = blessed $role ? $role->name : $role;
416 # if we are it,.. then return true
417 return 1 if $role_name eq $self->name;
418 # otherwise.. check our children
419 foreach my $role (@{$self->get_roles}) {
420 return 1 if $role->does_role($role_name);
425 sub find_method_by_name { (shift)->get_method(@_) }
427 ## ------------------------------------------------------------------
429 ## ------------------------------------------------------------------
432 my ($self, $other, %args) = @_;
435 || Moose->throw_error("You must pass in an blessed instance");
437 my $application_class;
438 if ($other->isa('Moose::Meta::Role')) {
439 $application_class = $self->application_to_role_class;
441 elsif ($other->isa('Moose::Meta::Class')) {
442 $application_class = $self->application_to_class_class;
445 $application_class = $self->application_to_instance_class;
448 Class::MOP::load_class($application_class);
450 my $deprecation_check = 0;
452 if ( exists $args{excludes} && !exists $args{'-excludes'} ) {
453 $args{'-excludes'} = delete $args{excludes};
454 $deprecation_check = 1;
456 if ( exists $args{alias} && !exists $args{'-alias'} ) {
457 $args{'-alias'} = delete $args{alias};
458 $deprecation_check = 1;
461 if ( $deprecation_check ) {
462 Moose::Deprecated::deprecated(
463 feature => 'alias or excludes',
465 'The alias and excludes options for role application'.
466 ' have been renamed -alias and -excludes'.
467 " (${\$other->name} is consuming ${\$self->name}".
468 " - do you need to upgrade ${\$other->name}?)"
472 if ( exists $args{'-excludes'} ) {
473 # I wish we had coercion here :)
474 $args{'-excludes'} = (
475 ref $args{'-excludes'} eq 'ARRAY'
477 : [ $args{'-excludes'} ]
481 return $application_class->new(%args)->apply($self, $other, \%args);
484 sub composition_class_roles { }
487 my ($class, @role_specs) = @_;
489 require Moose::Meta::Role::Composite;
491 my (@roles, %role_params);
492 while (@role_specs) {
493 my ($role, $params) = @{ splice @role_specs, 0, 1 };
497 : Class::MOP::class_of($role);
499 my $actual_role = $requested_role->_role_for_combination($params);
500 push @roles => $actual_role;
502 next unless defined $params;
503 $role_params{$actual_role->name} = $params;
506 my $c = Moose::Meta::Role::Composite->new(roles => \@roles);
507 return $c->apply_params(\%role_params);
510 sub _role_for_combination {
511 my ($self, $params) = @_;
516 my ( $role, $package_name, %options ) = @_;
518 $options{package} = $package_name;
520 (ref $options{attributes} eq 'HASH')
521 || confess "You must pass a HASH ref of attributes"
522 if exists $options{attributes};
524 (ref $options{methods} eq 'HASH')
525 || confess "You must pass a HASH ref of methods"
526 if exists $options{methods};
528 $options{meta_name} = 'meta'
529 unless exists $options{meta_name};
531 my (%initialize_options) = %options;
532 delete @initialize_options{qw(
541 my $meta = $role->initialize( $package_name => %initialize_options );
543 $meta->_instantiate_module( $options{version}, $options{authority} );
545 $meta->_add_meta_method($options{meta_name})
546 if defined $options{meta_name};
548 if (exists $options{attributes}) {
549 foreach my $attribute_name (keys %{$options{attributes}}) {
550 my $attr = $options{attributes}->{$attribute_name};
551 $meta->add_attribute(
552 $attribute_name => blessed $attr ? $attr : %{$attr} );
556 if (exists $options{methods}) {
557 foreach my $method_name (keys %{$options{methods}}) {
558 $meta->add_method($method_name, $options{methods}->{$method_name});
568 for my $meta (Class::MOP::get_all_metaclass_instances) {
569 next if $meta->name eq $self->name;
570 next unless $meta->isa('Moose::Meta::Class')
571 || $meta->isa('Moose::Meta::Role');
572 push @consumers, $meta->name
573 if $meta->does_role($self->name);
578 # anonymous roles. most of it is copied straight out of Class::MOP::Class.
579 # an intrepid hacker might find great riches if he unifies this code with that
580 # code in Class::MOP::Module or Class::MOP::Package
583 # this should be sufficient, if you have a
584 # use case where it is not, write a test and
586 my $ANON_ROLE_SERIAL = 0;
589 # we need a sufficiently annoying prefix
590 # this should suffice for now, this is
591 # used in a couple of places below, so
592 # need to put it up here for now.
593 my $ANON_ROLE_PREFIX = 'Moose::Meta::Role::__ANON__::SERIAL::';
597 no warnings 'uninitialized';
598 $self->name =~ /^$ANON_ROLE_PREFIX/;
601 sub create_anon_role {
602 my ($role, %options) = @_;
603 $options{weaken} = 1 unless exists $options{weaken};
604 my $package_name = $ANON_ROLE_PREFIX . ++$ANON_ROLE_SERIAL;
605 return $role->create($package_name, %options);
609 # this will only get called for
610 # anon-roles, all other calls
611 # are assumed to occur during
612 # global destruction and so don't
613 # really need to be handled explicitly
617 return if in_global_destruction(); # it'll happen soon anyway and this just makes things more complicated
619 no warnings 'uninitialized';
620 return unless $self->name =~ /^$ANON_ROLE_PREFIX/;
622 # XXX: is this necessary for us? I don't understand what it's doing
625 # Moose does a weird thing where it replaces the metaclass for
626 # class when fixing metaclass incompatibility. In that case,
627 # we don't want to clean out the namespace now. We can detect
628 # that because Moose will explicitly update the singleton
629 # cache in Class::MOP.
630 #my $current_meta = Class::MOP::get_metaclass_by_name($self->name);
631 #return if $current_meta ne $self;
633 my ($serial_id) = ($self->name =~ /^$ANON_ROLE_PREFIX(\d+)/);
635 foreach my $key (keys %{$ANON_ROLE_PREFIX . $serial_id}) {
636 delete ${$ANON_ROLE_PREFIX . $serial_id}{$key};
638 delete ${'main::' . $ANON_ROLE_PREFIX}{$serial_id . '::'};
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 It's 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.