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,
88 # create some helper methods
89 $META->add_method($methods->{add} => sub {
90 my ($self, @values) = @_;
91 $self->$attr_reader->{$_} = undef foreach @values;
92 }) if exists $methods->{add};
94 $META->add_method($methods->{get_keys} => sub {
96 keys %{$self->$attr_reader};
97 }) if exists $methods->{get_keys};
99 $META->add_method($methods->{get_values} => sub {
101 values %{$self->$attr_reader};
102 }) if exists $methods->{get_values};
104 $META->add_method($methods->{get} => sub {
105 my ($self, $name) = @_;
106 $self->$attr_reader->{$name}
107 }) if exists $methods->{get};
109 $META->add_method($methods->{existence} => sub {
110 my ($self, $name) = @_;
111 exists $self->$attr_reader->{$name} ? 1 : 0;
112 }) if exists $methods->{existence};
114 $META->add_method($methods->{remove} => sub {
115 my ($self, @values) = @_;
116 delete $self->$attr_reader->{$_} foreach @values;
117 }) if exists $methods->{remove};
120 $META->add_attribute(
122 reader => 'method_metaclass',
123 default => 'Moose::Meta::Role::Method',
126 $META->add_attribute(
127 'required_method_metaclass',
128 reader => 'required_method_metaclass',
129 default => 'Moose::Meta::Role::Method::Required',
132 $META->add_attribute(
133 'conflicting_method_metaclass',
134 reader => 'conflicting_method_metaclass',
135 default => 'Moose::Meta::Role::Method::Conflicting',
138 $META->add_attribute(
139 'application_to_class_class',
140 reader => 'application_to_class_class',
141 default => 'Moose::Meta::Role::Application::ToClass',
144 $META->add_attribute(
145 'application_to_role_class',
146 reader => 'application_to_role_class',
147 default => 'Moose::Meta::Role::Application::ToRole',
150 $META->add_attribute(
151 'application_to_instance_class',
152 reader => 'application_to_instance_class',
153 default => 'Moose::Meta::Role::Application::ToInstance',
156 $META->add_attribute(
157 'applied_attribute_metaclass',
158 reader => 'applied_attribute_metaclass',
159 default => 'Moose::Meta::Attribute',
162 # More or less copied from Moose::Meta::Class
167 if (defined(my $meta = Class::MOP::get_metaclass_by_name($pkg))) {
173 my $meta = $class->SUPER::initialize(
175 'attribute_metaclass' => 'Moose::Meta::Role::Attribute',
179 Class::MOP::weaken_metaclass($pkg) if $options{weaken};
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);
235 if (blessed $_[0] && ! $_[0]->isa('Moose::Meta::Role::Attribute') ) {
236 my $class = ref $_[0];
237 Moose->throw_error( "Cannot add a $class as an attribute to a role" );
239 elsif (!blessed($_[0]) && defined($_[0]) && $_[0] =~ /^\+(.*)/) {
240 Moose->throw_error( "has '+attr' is not supported in roles" );
243 return $self->SUPER::add_attribute(@_);
246 sub _attach_attribute {
247 my ( $self, $attribute ) = @_;
249 $attribute->attach_to_role($self);
252 sub add_required_methods {
257 if (!blessed($method)) {
258 $method = $self->required_method_metaclass->new(
262 $self->get_required_methods_map->{$method->name} = $method;
266 sub add_conflicting_method {
270 if (@_ == 1 && blessed($_[0])) {
274 $method = $self->conflicting_method_metaclass->new(@_);
277 $self->add_required_methods($method);
280 ## ------------------------------------------------------------------
284 # the before/around/after method modifiers are
285 # stored by name, but there can be many methods
286 # then associated with that name. So again we have
287 # lots of similar functionality, so we can do some
288 # meta-programmin' and save some time.
291 foreach my $modifier_type (qw[ before around after ]) {
293 my $attr_reader = "get_${modifier_type}_method_modifiers_map";
295 # create the attribute ...
296 $META->add_attribute("${modifier_type}_method_modifiers" => (
297 reader => $attr_reader,
298 default => sub { {} }
301 # and some helper methods ...
302 $META->add_method("get_${modifier_type}_method_modifiers" => sub {
303 my ($self, $method_name) = @_;
304 #return () unless exists $self->$attr_reader->{$method_name};
305 my $mm = $self->$attr_reader->{$method_name};
309 $META->add_method("has_${modifier_type}_method_modifiers" => sub {
310 my ($self, $method_name) = @_;
312 # for now we assume that if it exists,..
313 # it has at least one modifier in it
314 (exists $self->$attr_reader->{$method_name}) ? 1 : 0;
317 $META->add_method("add_${modifier_type}_method_modifier" => sub {
318 my ($self, $method_name, $method) = @_;
320 $self->$attr_reader->{$method_name} = []
321 unless exists $self->$attr_reader->{$method_name};
323 my $modifiers = $self->$attr_reader->{$method_name};
326 # check to see that we aren't adding the
327 # same code twice. We err in favor of the
328 # first on here, this may not be as expected
329 foreach my $modifier (@{$modifiers}) {
330 return if $modifier == $method;
333 push @{$modifiers} => $method;
338 ## ------------------------------------------------------------------
339 ## override method mofidiers
341 $META->add_attribute('override_method_modifiers' => (
342 reader => 'get_override_method_modifiers_map',
343 default => sub { {} }
347 # these are a little different because there
348 # can only be one per name, whereas the other
349 # method modifiers can have multiples.
352 sub add_override_method_modifier {
353 my ($self, $method_name, $method) = @_;
354 (!$self->has_method($method_name))
355 || Moose->throw_error("Cannot add an override of method '$method_name' " .
356 "because there is a local version of '$method_name'");
357 $self->get_override_method_modifiers_map->{$method_name} = $method;
360 sub has_override_method_modifier {
361 my ($self, $method_name) = @_;
363 # for now we assume that if it exists,..
364 # it has at least one modifier in it
365 (exists $self->get_override_method_modifiers_map->{$method_name}) ? 1 : 0;
368 sub get_override_method_modifier {
369 my ($self, $method_name) = @_;
370 $self->get_override_method_modifiers_map->{$method_name};
373 ## general list accessor ...
375 sub get_method_modifier_list {
376 my ($self, $modifier_type) = @_;
377 my $accessor = "get_${modifier_type}_method_modifiers_map";
378 keys %{$self->$accessor};
381 sub _meta_method_class { 'Moose::Meta::Method::Meta' }
383 ## ------------------------------------------------------------------
386 $META->add_attribute('roles' => (
387 reader => 'get_roles',
388 default => sub { [] }
392 my ($self, $role) = @_;
393 (blessed($role) && $role->isa('Moose::Meta::Role'))
394 || Moose->throw_error("Roles must be instances of Moose::Meta::Role");
395 push @{$self->get_roles} => $role;
396 $self->reset_package_cache_flag;
399 sub calculate_all_roles {
405 $_->calculate_all_roles
406 } @{ $self->get_roles });
410 my ($self, $role) = @_;
412 || Moose->throw_error("You must supply a role name to look for");
413 my $role_name = blessed $role ? $role->name : $role;
414 # if we are it,.. then return true
415 return 1 if $role_name eq $self->name;
416 # otherwise.. check our children
417 foreach my $role (@{$self->get_roles}) {
418 return 1 if $role->does_role($role_name);
423 sub find_method_by_name { (shift)->get_method(@_) }
425 ## ------------------------------------------------------------------
427 ## ------------------------------------------------------------------
430 my ($self, $other, %args) = @_;
433 || Moose->throw_error("You must pass in an blessed instance");
435 my $application_class;
436 if ($other->isa('Moose::Meta::Role')) {
437 $application_class = $self->application_to_role_class;
439 elsif ($other->isa('Moose::Meta::Class')) {
440 $application_class = $self->application_to_class_class;
443 $application_class = $self->application_to_instance_class;
446 Class::MOP::load_class($application_class);
448 my $deprecation_check = 0;
450 if ( exists $args{excludes} && !exists $args{'-excludes'} ) {
451 $args{'-excludes'} = delete $args{excludes};
452 $deprecation_check = 1;
454 if ( exists $args{alias} && !exists $args{'-alias'} ) {
455 $args{'-alias'} = delete $args{alias};
456 $deprecation_check = 1;
459 if ( $deprecation_check ) {
460 Moose::Deprecated::deprecated(
461 feature => 'alias or excludes',
463 'The alias and excludes options for role application'.
464 ' have been renamed -alias and -excludes'.
465 " (${\$other->name} is consuming ${\$self->name}".
466 " - do you need to upgrade ${\$other->name}?)"
470 if ( exists $args{'-excludes'} ) {
471 # I wish we had coercion here :)
472 $args{'-excludes'} = (
473 ref $args{'-excludes'} eq 'ARRAY'
475 : [ $args{'-excludes'} ]
479 return $application_class->new(%args)->apply($self, $other, \%args);
482 sub composition_class_roles { }
485 my ($class, @role_specs) = @_;
487 require Moose::Meta::Role::Composite;
489 my (@roles, %role_params);
490 while (@role_specs) {
491 my ($role, $params) = @{ splice @role_specs, 0, 1 };
495 : Class::MOP::class_of($role);
497 my $actual_role = $requested_role->_role_for_combination($params);
498 push @roles => $actual_role;
500 next unless defined $params;
501 $role_params{$actual_role->name} = $params;
504 my $c = Moose::Meta::Role::Composite->new(roles => \@roles);
505 return $c->apply_params(\%role_params);
508 sub _role_for_combination {
509 my ($self, $params) = @_;
514 my ( $role, $package_name, %options ) = @_;
516 $options{package} = $package_name;
518 (ref $options{attributes} eq 'HASH')
519 || confess "You must pass a HASH ref of attributes"
520 if exists $options{attributes};
522 (ref $options{methods} eq 'HASH')
523 || confess "You must pass a HASH ref of methods"
524 if exists $options{methods};
526 $options{meta_name} = 'meta'
527 unless exists $options{meta_name};
529 my (%initialize_options) = %options;
530 delete @initialize_options{qw(
539 my $meta = $role->initialize( $package_name => %initialize_options );
541 $meta->_instantiate_module( $options{version}, $options{authority} );
543 $meta->_add_meta_method($options{meta_name})
544 if defined $options{meta_name};
546 if (exists $options{attributes}) {
547 foreach my $attribute_name (keys %{$options{attributes}}) {
548 my $attr = $options{attributes}->{$attribute_name};
549 $meta->add_attribute(
550 $attribute_name => blessed $attr ? $attr : %{$attr} );
554 if (exists $options{methods}) {
555 foreach my $method_name (keys %{$options{methods}}) {
556 $meta->add_method($method_name, $options{methods}->{$method_name});
566 for my $meta (Class::MOP::get_all_metaclass_instances) {
567 next if $meta->name eq $self->name;
568 next unless $meta->isa('Moose::Meta::Class')
569 || $meta->isa('Moose::Meta::Role');
570 push @consumers, $meta->name
571 if $meta->does_role($self->name);
576 # anonymous roles. most of it is copied straight out of Class::MOP::Class.
577 # an intrepid hacker might find great riches if he unifies this code with that
578 # code in Class::MOP::Module or Class::MOP::Package
581 # this should be sufficient, if you have a
582 # use case where it is not, write a test and
584 my $ANON_ROLE_SERIAL = 0;
587 # we need a sufficiently annoying prefix
588 # this should suffice for now, this is
589 # used in a couple of places below, so
590 # need to put it up here for now.
591 my $ANON_ROLE_PREFIX = 'Moose::Meta::Role::__ANON__::SERIAL::';
595 no warnings 'uninitialized';
596 $self->name =~ /^$ANON_ROLE_PREFIX/;
599 sub create_anon_role {
600 my ($role, %options) = @_;
601 $options{weaken} = 1 unless exists $options{weaken};
602 my $package_name = $ANON_ROLE_PREFIX . ++$ANON_ROLE_SERIAL;
603 return $role->create($package_name, %options);
607 # this will only get called for
608 # anon-roles, all other calls
609 # are assumed to occur during
610 # global destruction and so don't
611 # really need to be handled explicitly
615 return if in_global_destruction(); # it'll happen soon anyway and this just makes things more complicated
617 no warnings 'uninitialized';
618 return unless $self->name =~ /^$ANON_ROLE_PREFIX/;
620 # XXX: is this necessary for us? I don't understand what it's doing
623 # Moose does a weird thing where it replaces the metaclass for
624 # class when fixing metaclass incompatibility. In that case,
625 # we don't want to clean out the namespace now. We can detect
626 # that because Moose will explicitly update the singleton
627 # cache in Class::MOP.
628 #my $current_meta = Class::MOP::get_metaclass_by_name($self->name);
629 #return if $current_meta ne $self;
631 my ($serial_id) = ($self->name =~ /^$ANON_ROLE_PREFIX(\d+)/);
633 foreach my $key (keys %{$ANON_ROLE_PREFIX . $serial_id}) {
634 delete ${$ANON_ROLE_PREFIX . $serial_id}{$key};
636 delete ${'main::' . $ANON_ROLE_PREFIX}{$serial_id . '::'};
640 #####################################################################
642 ## This is Moose::Meta::Role as defined by Moose (plus the use of
643 ## MooseX::AttributeHelpers module). It is here as a reference to
644 ## make it easier to see what is happening above with all the meta
646 #####################################################################
649 # metaclass => 'Array',
650 # reader => 'get_roles',
651 # isa => 'ArrayRef[Moose::Meta::Role]',
652 # default => sub { [] },
654 # 'push' => 'add_role',
658 # has 'excluded_roles_map' => (
659 # metaclass => 'Hash',
660 # reader => 'get_excluded_roles_map',
661 # isa => 'HashRef[Str]',
663 # # Not exactly set, cause it sets multiple
664 # 'set' => 'add_excluded_roles',
665 # 'keys' => 'get_excluded_roles_list',
666 # 'exists' => 'excludes_role',
670 # has 'required_methods' => (
671 # metaclass => 'Hash',
672 # reader => 'get_required_methods_map',
673 # isa => 'HashRef[Moose::Meta::Role::Method::Required]',
675 # # not exactly set, or delete since it works for multiple
676 # 'set' => 'add_required_methods',
677 # 'delete' => 'remove_required_methods',
678 # 'keys' => 'get_required_method_list',
679 # 'exists' => 'requires_method',
683 # # the before, around and after modifiers are
684 # # HASH keyed by method-name, with ARRAY of
685 # # CODE refs to apply in that order
687 # has 'before_method_modifiers' => (
688 # metaclass => 'Hash',
689 # reader => 'get_before_method_modifiers_map',
690 # isa => 'HashRef[ArrayRef[CodeRef]]',
692 # 'keys' => 'get_before_method_modifiers',
693 # 'exists' => 'has_before_method_modifiers',
694 # # This actually makes sure there is an
695 # # ARRAY at the given key, and pushed onto
696 # # it. It also checks for duplicates as well
697 # # 'add' => 'add_before_method_modifier'
701 # has 'after_method_modifiers' => (
702 # metaclass => 'Hash',
703 # reader =>'get_after_method_modifiers_map',
704 # isa => 'HashRef[ArrayRef[CodeRef]]',
706 # 'keys' => 'get_after_method_modifiers',
707 # 'exists' => 'has_after_method_modifiers',
708 # # This actually makes sure there is an
709 # # ARRAY at the given key, and pushed onto
710 # # it. It also checks for duplicates as well
711 # # 'add' => 'add_after_method_modifier'
715 # has 'around_method_modifiers' => (
716 # metaclass => 'Hash',
717 # reader =>'get_around_method_modifiers_map',
718 # isa => 'HashRef[ArrayRef[CodeRef]]',
720 # 'keys' => 'get_around_method_modifiers',
721 # 'exists' => 'has_around_method_modifiers',
722 # # This actually makes sure there is an
723 # # ARRAY at the given key, and pushed onto
724 # # it. It also checks for duplicates as well
725 # # 'add' => 'add_around_method_modifier'
729 # # override is similar to the other modifiers
730 # # except that it is not an ARRAY of code refs
731 # # but instead just a single name->code mapping
733 # has 'override_method_modifiers' => (
734 # metaclass => 'Hash',
735 # reader =>'get_override_method_modifiers_map',
736 # isa => 'HashRef[CodeRef]',
738 # 'keys' => 'get_override_method_modifier',
739 # 'exists' => 'has_override_method_modifier',
740 # 'add' => 'add_override_method_modifier', # checks for local method ..
744 #####################################################################
749 # ABSTRACT: The Moose Role metaclass
757 This class is a subclass of L<Class::MOP::Module> that provides
758 additional Moose-specific functionality.
760 It's API looks a lot like L<Moose::Meta::Class>, but internally it
761 implements many things differently. This may change in the future.
765 C<Moose::Meta::Role> is a subclass of L<Class::MOP::Module>.
773 =item B<< Moose::Meta::Role->initialize($role_name) >>
775 This method creates a new role object with the provided name.
777 =item B<< Moose::Meta::Role->combine( [ $role => { ... } ], [ $role ], ... ) >>
779 This method accepts a list of array references. Each array reference
780 should contain a role name or L<Moose::Meta::Role> object as its first element. The second element is
781 an optional hash reference. The hash reference can contain C<-excludes>
782 and C<-alias> keys to control how methods are composed from the role.
784 The return value is a new L<Moose::Meta::Role::Composite> that
785 represents the combined roles.
787 =item B<< $metarole->composition_class_roles >>
789 When combining multiple roles using C<combine>, this method is used to obtain a
790 list of role names to be applied to the L<Moose::Meta::Role::Composite>
791 instance returned by C<combine>. The default implementation returns an empty
792 list. Extensions that need to hook into role combination may wrap this method
793 to return additional role names.
795 =item B<< Moose::Meta::Role->create($name, %options) >>
797 This method is identical to the L<Moose::Meta::Class> C<create>
800 =item B<< Moose::Meta::Role->create_anon_role >>
802 This method is identical to the L<Moose::Meta::Class>
803 C<create_anon_class> method.
805 =item B<< $metarole->is_anon_role >>
807 Returns true if the role is an anonymous role.
809 =item B<< $metarole->consumers >>
811 Returns a list of names of classes and roles which consume this role.
815 =head2 Role application
819 =item B<< $metarole->apply( $thing, @options ) >>
821 This method applies a role to the given C<$thing>. That can be another
822 L<Moose::Meta::Role>, object, a L<Moose::Meta::Class> object, or a
823 (non-meta) object instance.
825 The options are passed directly to the constructor for the appropriate
826 L<Moose::Meta::Role::Application> subclass.
828 Note that this will apply the role even if the C<$thing> in question already
829 C<does> this role. L<Moose::Util/does_role> is a convenient wrapper for
830 finding out if role application is necessary.
834 =head2 Roles and other roles
838 =item B<< $metarole->get_roles >>
840 This returns an array reference of roles which this role does. This
841 list may include duplicates.
843 =item B<< $metarole->calculate_all_roles >>
845 This returns a I<unique> list of all roles that this role does, and
846 all the roles that its roles do.
848 =item B<< $metarole->does_role($role) >>
850 Given a role I<name> or L<Moose::Meta::Role> object, returns true if this role
853 =item B<< $metarole->add_role($role) >>
855 Given a L<Moose::Meta::Role> object, this adds the role to the list of
856 roles that the role does.
858 =item B<< $metarole->get_excluded_roles_list >>
860 Returns a list of role names which this role excludes.
862 =item B<< $metarole->excludes_role($role_name) >>
864 Given a role I<name>, returns true if this role excludes the named
867 =item B<< $metarole->add_excluded_roles(@role_names) >>
869 Given one or more role names, adds those roles to the list of excluded
876 The methods for dealing with a role's methods are all identical in API
877 and behavior to the same methods in L<Class::MOP::Class>.
881 =item B<< $metarole->method_metaclass >>
883 Returns the method metaclass name for the role. This defaults to
884 L<Moose::Meta::Role::Method>.
886 =item B<< $metarole->get_method($name) >>
888 =item B<< $metarole->has_method($name) >>
890 =item B<< $metarole->add_method( $name, $body ) >>
892 =item B<< $metarole->get_method_list >>
894 =item B<< $metarole->find_method_by_name($name) >>
896 These methods are all identical to the methods of the same name in
897 L<Class::MOP::Package>
903 As with methods, the methods for dealing with a role's attribute are
904 all identical in API and behavior to the same methods in
905 L<Class::MOP::Class>.
907 However, attributes stored in this class are I<not> stored as
908 objects. Rather, the attribute definition is stored as a hash
909 reference. When a role is composed into a class, this hash reference
910 is passed directly to the metaclass's C<add_attribute> method.
912 This is quite likely to change in the future.
916 =item B<< $metarole->get_attribute($attribute_name) >>
918 =item B<< $metarole->has_attribute($attribute_name) >>
920 =item B<< $metarole->get_attribute_list >>
922 =item B<< $metarole->add_attribute($name, %options) >>
924 =item B<< $metarole->remove_attribute($attribute_name) >>
928 =head2 Required methods
932 =item B<< $metarole->get_required_method_list >>
934 Returns the list of methods required by the role.
936 =item B<< $metarole->requires_method($name) >>
938 Returns true if the role requires the named method.
940 =item B<< $metarole->add_required_methods(@names) >>
942 Adds the named methods to the role's list of required methods.
944 =item B<< $metarole->remove_required_methods(@names) >>
946 Removes the named methods from the role's list of required methods.
948 =item B<< $metarole->add_conflicting_method(%params) >>
950 Instantiate the parameters as a L<Moose::Meta::Role::Method::Conflicting>
951 object, then add it to the required method list.
955 =head2 Method modifiers
957 These methods act like their counterparts in L<Class::MOP::Class> and
958 L<Moose::Meta::Class>.
960 However, method modifiers are simply stored internally, and are not
961 applied until the role itself is applied to a class.
965 =item B<< $metarole->add_after_method_modifier($method_name, $method) >>
967 =item B<< $metarole->add_around_method_modifier($method_name, $method) >>
969 =item B<< $metarole->add_before_method_modifier($method_name, $method) >>
971 =item B<< $metarole->add_override_method_modifier($method_name, $method) >>
973 These methods all add an appropriate modifier to the internal list of
976 =item B<< $metarole->has_after_method_modifiers >>
978 =item B<< $metarole->has_around_method_modifiers >>
980 =item B<< $metarole->has_before_method_modifiers >>
982 =item B<< $metarole->has_override_method_modifier >>
984 Return true if the role has any modifiers of the given type.
986 =item B<< $metarole->get_after_method_modifiers($method_name) >>
988 =item B<< $metarole->get_around_method_modifiers($method_name) >>
990 =item B<< $metarole->get_before_method_modifiers($method_name) >>
992 Given a method name, returns a list of the appropriate modifiers for
995 =item B<< $metarole->get_override_method_modifier($method_name) >>
997 Given a method name, returns the override method modifier for that
998 method, if it has one.
1002 =head2 Introspection
1006 =item B<< Moose::Meta::Role->meta >>
1008 This will return a L<Class::MOP::Class> instance for this class.
1014 See L<Moose/BUGS> for details on reporting bugs.