1 package Moose::Meta::Role;
7 use Class::Load qw(load_class);
8 use Scalar::Util 'blessed';
9 use Devel::GlobalDestruction 'in_global_destruction';
11 use Moose::Meta::Class;
12 use Moose::Meta::Role::Attribute;
13 use Moose::Meta::Role::Method;
14 use Moose::Meta::Role::Method::Required;
15 use Moose::Meta::Role::Method::Conflicting;
16 use Moose::Meta::Method::Meta;
17 use Moose::Util qw( ensure_all_roles );
18 use Class::MOP::MiniTrait;
20 use base 'Class::MOP::Module',
21 'Class::MOP::Mixin::HasAttributes',
22 'Class::MOP::Mixin::HasMethods';
24 Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait');
26 ## ------------------------------------------------------------------
28 ## I normally don't do this, but I am doing
29 ## a whole bunch of meta-programmin in this
30 ## module, so it just makes sense. For a clearer
31 ## picture of what is going on in the next
32 ## several lines of code, look at the really
33 ## big comment at the end of this file (right
36 ## ------------------------------------------------------------------
38 my $META = __PACKAGE__->meta;
40 ## ------------------------------------------------------------------
44 # since roles are lazy, we hold all the attributes
45 # of the individual role in 'stasis' until which
46 # time when it is applied to a class. This means
47 # keeping a lot of things in hash maps, so we are
48 # using a little of that meta-programmin' magic
49 # here an saving lots of extra typin. And since
50 # many of these attributes above require similar
51 # functionality to support them, so we again use
52 # the wonders of meta-programmin' to deliver a
53 # very compact solution to this normally verbose
59 name => 'excluded_roles_map',
60 attr_reader => 'get_excluded_roles_map' ,
62 add => 'add_excluded_roles',
63 get_keys => 'get_excluded_roles_list',
64 existence => 'excludes_role',
68 name => 'required_methods',
69 attr_reader => 'get_required_methods_map',
71 remove => 'remove_required_methods',
72 get_values => 'get_required_method_list',
73 existence => 'requires_method',
78 my $attr_reader = $action->{attr_reader};
79 my $methods = $action->{methods};
81 # create the attribute
82 $META->add_attribute($action->{name} => (
83 reader => $attr_reader,
84 default => sub { {} },
85 Class::MOP::_definition_context(),
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',
124 Class::MOP::_definition_context(),
127 $META->add_attribute(
128 'required_method_metaclass',
129 reader => 'required_method_metaclass',
130 default => 'Moose::Meta::Role::Method::Required',
131 Class::MOP::_definition_context(),
134 $META->add_attribute(
135 'conflicting_method_metaclass',
136 reader => 'conflicting_method_metaclass',
137 default => 'Moose::Meta::Role::Method::Conflicting',
138 Class::MOP::_definition_context(),
141 $META->add_attribute(
142 'application_to_class_class',
143 reader => 'application_to_class_class',
144 default => 'Moose::Meta::Role::Application::ToClass',
145 Class::MOP::_definition_context(),
148 $META->add_attribute(
149 'application_to_role_class',
150 reader => 'application_to_role_class',
151 default => 'Moose::Meta::Role::Application::ToRole',
152 Class::MOP::_definition_context(),
155 $META->add_attribute(
156 'application_to_instance_class',
157 reader => 'application_to_instance_class',
158 default => 'Moose::Meta::Role::Application::ToInstance',
159 Class::MOP::_definition_context(),
162 $META->add_attribute(
163 'applied_attribute_metaclass',
164 reader => 'applied_attribute_metaclass',
165 default => 'Moose::Meta::Attribute',
166 Class::MOP::_definition_context(),
169 # More or less copied from Moose::Meta::Class
173 unshift @args, 'package' if @args % 2;
175 my $package = delete $opts{package};
176 return Class::MOP::get_metaclass_by_name($package)
177 || $class->SUPER::initialize($package,
178 'attribute_metaclass' => 'Moose::Meta::Role::Attribute',
187 my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg);
189 my %existing_classes;
191 %existing_classes = map { $_ => $meta->$_() } qw(
194 wrapped_method_metaclass
195 required_method_metaclass
196 conflicting_method_metaclass
197 application_to_class_class
198 application_to_role_class
199 application_to_instance_class
200 applied_attribute_metaclass
205 $options{weaken} = Class::MOP::metaclass_is_weak($meta->name)
206 if !exists $options{weaken}
208 && $meta->isa('Moose::Meta::Role');
210 # don't need to remove generated metaobjects here yet, since we don't
211 # yet generate anything in roles. this may change in the future though...
212 # keep an eye on that
213 my $new_meta = $self->SUPER::reinitialize(
218 $new_meta->_restore_metaobjects_from($meta)
219 if $meta && $meta->isa('Moose::Meta::Role');
223 sub _restore_metaobjects_from {
227 $self->_restore_metamethods_from($old_meta);
228 $self->_restore_metaattributes_from($old_meta);
230 for my $role ( @{ $old_meta->get_roles } ) {
231 $self->add_role($role);
238 if (blessed $_[0] && ! $_[0]->isa('Moose::Meta::Role::Attribute') ) {
239 my $class = ref $_[0];
240 Moose->throw_error( "Cannot add a $class as an attribute to a role" );
242 elsif (!blessed($_[0]) && defined($_[0]) && $_[0] =~ /^\+(.*)/) {
243 Moose->throw_error( "has '+attr' is not supported in roles" );
246 return $self->SUPER::add_attribute(@_);
249 sub _attach_attribute {
250 my ( $self, $attribute ) = @_;
252 $attribute->attach_to_role($self);
255 sub add_required_methods {
260 if (!blessed($method)) {
261 $method = $self->required_method_metaclass->new(
265 $self->get_required_methods_map->{$method->name} = $method;
269 sub add_conflicting_method {
273 if (@_ == 1 && blessed($_[0])) {
277 $method = $self->conflicting_method_metaclass->new(@_);
280 $self->add_required_methods($method);
283 ## ------------------------------------------------------------------
287 # the before/around/after method modifiers are
288 # stored by name, but there can be many methods
289 # then associated with that name. So again we have
290 # lots of similar functionality, so we can do some
291 # meta-programmin' and save some time.
294 foreach my $modifier_type (qw[ before around after ]) {
296 my $attr_reader = "get_${modifier_type}_method_modifiers_map";
298 # create the attribute ...
299 $META->add_attribute("${modifier_type}_method_modifiers" => (
300 reader => $attr_reader,
301 default => sub { {} },
302 Class::MOP::_definition_context(),
305 # and some helper methods ...
306 $META->add_method("get_${modifier_type}_method_modifiers" => sub {
307 my ($self, $method_name) = @_;
308 #return () unless exists $self->$attr_reader->{$method_name};
309 my $mm = $self->$attr_reader->{$method_name};
313 $META->add_method("has_${modifier_type}_method_modifiers" => sub {
314 my ($self, $method_name) = @_;
316 # for now we assume that if it exists,..
317 # it has at least one modifier in it
318 (exists $self->$attr_reader->{$method_name}) ? 1 : 0;
321 $META->add_method("add_${modifier_type}_method_modifier" => sub {
322 my ($self, $method_name, $method) = @_;
324 $self->$attr_reader->{$method_name} = []
325 unless exists $self->$attr_reader->{$method_name};
327 my $modifiers = $self->$attr_reader->{$method_name};
330 # check to see that we aren't adding the
331 # same code twice. We err in favor of the
332 # first on here, this may not be as expected
333 foreach my $modifier (@{$modifiers}) {
334 return if $modifier == $method;
337 push @{$modifiers} => $method;
342 ## ------------------------------------------------------------------
343 ## override method mofidiers
345 $META->add_attribute('override_method_modifiers' => (
346 reader => 'get_override_method_modifiers_map',
347 default => sub { {} },
348 Class::MOP::_definition_context(),
352 # these are a little different because there
353 # can only be one per name, whereas the other
354 # method modifiers can have multiples.
357 sub add_override_method_modifier {
358 my ($self, $method_name, $method) = @_;
359 (!$self->has_method($method_name))
360 || Moose->throw_error("Cannot add an override of method '$method_name' " .
361 "because there is a local version of '$method_name'");
362 $self->get_override_method_modifiers_map->{$method_name} = $method;
365 sub has_override_method_modifier {
366 my ($self, $method_name) = @_;
368 # for now we assume that if it exists,..
369 # it has at least one modifier in it
370 (exists $self->get_override_method_modifiers_map->{$method_name}) ? 1 : 0;
373 sub get_override_method_modifier {
374 my ($self, $method_name) = @_;
375 $self->get_override_method_modifiers_map->{$method_name};
378 ## general list accessor ...
380 sub get_method_modifier_list {
381 my ($self, $modifier_type) = @_;
382 my $accessor = "get_${modifier_type}_method_modifiers_map";
383 keys %{$self->$accessor};
386 sub _meta_method_class { 'Moose::Meta::Method::Meta' }
388 ## ------------------------------------------------------------------
391 $META->add_attribute('roles' => (
392 reader => 'get_roles',
393 default => sub { [] },
394 Class::MOP::_definition_context(),
398 my ($self, $role) = @_;
399 (blessed($role) && $role->isa('Moose::Meta::Role'))
400 || Moose->throw_error("Roles must be instances of Moose::Meta::Role");
401 push @{$self->get_roles} => $role;
402 $self->reset_package_cache_flag;
405 sub calculate_all_roles {
411 $_->calculate_all_roles
412 } @{ $self->get_roles });
416 my ($self, $role) = @_;
418 || Moose->throw_error("You must supply a role name to look for");
419 my $role_name = blessed $role ? $role->name : $role;
420 # if we are it,.. then return true
421 return 1 if $role_name eq $self->name;
422 # otherwise.. check our children
423 foreach my $role (@{$self->get_roles}) {
424 return 1 if $role->does_role($role_name);
429 sub find_method_by_name { (shift)->get_method(@_) }
431 ## ------------------------------------------------------------------
433 ## ------------------------------------------------------------------
436 my ($self, $other, %args) = @_;
439 || Moose->throw_error("You must pass in an blessed instance");
441 my $application_class;
442 if ($other->isa('Moose::Meta::Role')) {
443 $application_class = $self->application_to_role_class;
445 elsif ($other->isa('Moose::Meta::Class')) {
446 $application_class = $self->application_to_class_class;
449 $application_class = $self->application_to_instance_class;
452 load_class($application_class);
454 if ( exists $args{'-excludes'} ) {
455 # I wish we had coercion here :)
456 $args{'-excludes'} = (
457 ref $args{'-excludes'} eq 'ARRAY'
459 : [ $args{'-excludes'} ]
463 return $application_class->new(%args)->apply($self, $other, \%args);
466 sub composition_class_roles { }
469 my ($class, @role_specs) = @_;
471 require Moose::Meta::Role::Composite;
473 my (@roles, %role_params);
474 while (@role_specs) {
475 my ($role, $params) = @{ splice @role_specs, 0, 1 };
479 : Class::MOP::class_of($role);
481 my $actual_role = $requested_role->_role_for_combination($params);
482 push @roles => $actual_role;
484 next unless defined $params;
485 $role_params{$actual_role->name} = $params;
488 my $c = Moose::Meta::Role::Composite->new(roles => \@roles);
489 return $c->apply_params(\%role_params);
492 sub _role_for_combination {
493 my ($self, $params) = @_;
501 unshift @args, 'package' if @args % 2 == 1;
504 (ref $options{attributes} eq 'HASH')
505 || Moose::Util::throw "You must pass a HASH ref of attributes"
506 if exists $options{attributes};
508 (ref $options{methods} eq 'HASH')
509 || Moose::Util::throw "You must pass a HASH ref of methods"
510 if exists $options{methods};
512 (ref $options{roles} eq 'ARRAY')
513 || Moose::Util::throw "You must pass an ARRAY ref of roles"
514 if exists $options{roles};
516 my $package = delete $options{package};
517 my $roles = delete $options{roles};
518 my $attributes = delete $options{attributes};
519 my $methods = delete $options{methods};
520 my $meta_name = exists $options{meta_name}
521 ? delete $options{meta_name}
524 my $meta = $class->SUPER::create($package => %options);
526 $meta->_add_meta_method($meta_name)
527 if defined $meta_name;
529 if (defined $attributes) {
530 foreach my $attribute_name (keys %{$attributes}) {
531 my $attr = $attributes->{$attribute_name};
532 $meta->add_attribute(
533 $attribute_name => blessed $attr ? $attr : %{$attr} );
537 if (defined $methods) {
538 foreach my $method_name (keys %{$methods}) {
539 $meta->add_method($method_name, $methods->{$method_name});
544 Moose::Util::apply_all_roles($meta, @$roles);
553 for my $meta (Class::MOP::get_all_metaclass_instances) {
554 next if $meta->name eq $self->name;
555 next unless $meta->isa('Moose::Meta::Class')
556 || $meta->isa('Moose::Meta::Role');
557 push @consumers, $meta->name
558 if $meta->does_role($self->name);
563 # XXX: something more intelligent here?
564 sub _anon_package_prefix { 'Moose::Meta::Role::__ANON__::SERIAL::' }
566 sub create_anon_role { shift->create_anon(@_) }
567 sub is_anon_role { shift->is_anon(@_) }
569 sub _anon_cache_key {
573 # XXX fix this duplication (see MMC::_anon_cache_key
574 my $roles = Data::OptList::mkopt(($options{roles} || []), {
576 val_test => sub { ref($_[0]) eq 'HASH' },
580 for my $role_spec (@$roles) {
581 my ($role, $params) = @$role_spec;
582 $params = { %$params };
584 my $key = blessed($role) ? $role->name : $role;
586 if ($params && %$params) {
587 my $alias = delete $params->{'-alias'}
588 || delete $params->{'alias'}
590 my $excludes = delete $params->{'-excludes'}
591 || delete $params->{'excludes'}
593 $excludes = [$excludes] unless ref($excludes) eq 'ARRAY';
596 warn "Roles with parameters cannot be cached. Consider "
597 . "applying the parameters before calling "
598 . "create_anon_class, or using 'weaken => 0' instead";
602 my $alias_key = join('%',
603 map { $_ => $alias->{$_} } sort keys %$alias
605 my $excludes_key = join('%',
608 $key .= '<' . join('+', 'a', $alias_key, 'e', $excludes_key) . '>';
611 push @role_keys, $key;
614 # Makes something like Role|Role::1
615 return join('|', sort @role_keys);
618 #####################################################################
620 ## This is Moose::Meta::Role as defined by Moose (plus the use of
621 ## MooseX::AttributeHelpers module). It is here as a reference to
622 ## make it easier to see what is happening above with all the meta
624 #####################################################################
627 # metaclass => 'Array',
628 # reader => 'get_roles',
629 # isa => 'ArrayRef[Moose::Meta::Role]',
630 # default => sub { [] },
632 # 'push' => 'add_role',
636 # has 'excluded_roles_map' => (
637 # metaclass => 'Hash',
638 # reader => 'get_excluded_roles_map',
639 # isa => 'HashRef[Str]',
641 # # Not exactly set, cause it sets multiple
642 # 'set' => 'add_excluded_roles',
643 # 'keys' => 'get_excluded_roles_list',
644 # 'exists' => 'excludes_role',
648 # has 'required_methods' => (
649 # metaclass => 'Hash',
650 # reader => 'get_required_methods_map',
651 # isa => 'HashRef[Moose::Meta::Role::Method::Required]',
653 # # not exactly set, or delete since it works for multiple
654 # 'set' => 'add_required_methods',
655 # 'delete' => 'remove_required_methods',
656 # 'keys' => 'get_required_method_list',
657 # 'exists' => 'requires_method',
661 # # the before, around and after modifiers are
662 # # HASH keyed by method-name, with ARRAY of
663 # # CODE refs to apply in that order
665 # has 'before_method_modifiers' => (
666 # metaclass => 'Hash',
667 # reader => 'get_before_method_modifiers_map',
668 # isa => 'HashRef[ArrayRef[CodeRef]]',
670 # 'keys' => 'get_before_method_modifiers',
671 # 'exists' => 'has_before_method_modifiers',
672 # # This actually makes sure there is an
673 # # ARRAY at the given key, and pushed onto
674 # # it. It also checks for duplicates as well
675 # # 'add' => 'add_before_method_modifier'
679 # has 'after_method_modifiers' => (
680 # metaclass => 'Hash',
681 # reader =>'get_after_method_modifiers_map',
682 # isa => 'HashRef[ArrayRef[CodeRef]]',
684 # 'keys' => 'get_after_method_modifiers',
685 # 'exists' => 'has_after_method_modifiers',
686 # # This actually makes sure there is an
687 # # ARRAY at the given key, and pushed onto
688 # # it. It also checks for duplicates as well
689 # # 'add' => 'add_after_method_modifier'
693 # has 'around_method_modifiers' => (
694 # metaclass => 'Hash',
695 # reader =>'get_around_method_modifiers_map',
696 # isa => 'HashRef[ArrayRef[CodeRef]]',
698 # 'keys' => 'get_around_method_modifiers',
699 # 'exists' => 'has_around_method_modifiers',
700 # # This actually makes sure there is an
701 # # ARRAY at the given key, and pushed onto
702 # # it. It also checks for duplicates as well
703 # # 'add' => 'add_around_method_modifier'
707 # # override is similar to the other modifiers
708 # # except that it is not an ARRAY of code refs
709 # # but instead just a single name->code mapping
711 # has 'override_method_modifiers' => (
712 # metaclass => 'Hash',
713 # reader =>'get_override_method_modifiers_map',
714 # isa => 'HashRef[CodeRef]',
716 # 'keys' => 'get_override_method_modifier',
717 # 'exists' => 'has_override_method_modifier',
718 # 'add' => 'add_override_method_modifier', # checks for local method ..
722 #####################################################################
727 # ABSTRACT: The Moose Role metaclass
735 This class is a subclass of L<Class::MOP::Module> that provides
736 additional Moose-specific functionality.
738 Its API looks a lot like L<Moose::Meta::Class>, but internally it
739 implements many things differently. This may change in the future.
743 C<Moose::Meta::Role> is a subclass of L<Class::MOP::Module>.
751 =item B<< Moose::Meta::Role->initialize($role_name) >>
753 This method creates a new role object with the provided name.
755 =item B<< Moose::Meta::Role->combine( [ $role => { ... } ], [ $role ], ... ) >>
757 This method accepts a list of array references. Each array reference
758 should contain a role name or L<Moose::Meta::Role> object as its first element. The second element is
759 an optional hash reference. The hash reference can contain C<-excludes>
760 and C<-alias> keys to control how methods are composed from the role.
762 The return value is a new L<Moose::Meta::Role::Composite> that
763 represents the combined roles.
765 =item B<< $metarole->composition_class_roles >>
767 When combining multiple roles using C<combine>, this method is used to obtain a
768 list of role names to be applied to the L<Moose::Meta::Role::Composite>
769 instance returned by C<combine>. The default implementation returns an empty
770 list. Extensions that need to hook into role combination may wrap this method
771 to return additional role names.
773 =item B<< Moose::Meta::Role->create($name, %options) >>
775 This method is identical to the L<Moose::Meta::Class> C<create>
778 =item B<< Moose::Meta::Role->create_anon_role >>
780 This method is identical to the L<Moose::Meta::Class>
781 C<create_anon_class> method.
783 =item B<< $metarole->is_anon_role >>
785 Returns true if the role is an anonymous role.
787 =item B<< $metarole->consumers >>
789 Returns a list of names of classes and roles which consume this role.
793 =head2 Role application
797 =item B<< $metarole->apply( $thing, @options ) >>
799 This method applies a role to the given C<$thing>. That can be another
800 L<Moose::Meta::Role>, object, a L<Moose::Meta::Class> object, or a
801 (non-meta) object instance.
803 The options are passed directly to the constructor for the appropriate
804 L<Moose::Meta::Role::Application> subclass.
806 Note that this will apply the role even if the C<$thing> in question already
807 C<does> this role. L<Moose::Util/does_role> is a convenient wrapper for
808 finding out if role application is necessary.
812 =head2 Roles and other roles
816 =item B<< $metarole->get_roles >>
818 This returns an array reference of roles which this role does. This
819 list may include duplicates.
821 =item B<< $metarole->calculate_all_roles >>
823 This returns a I<unique> list of all roles that this role does, and
824 all the roles that its roles do.
826 =item B<< $metarole->does_role($role) >>
828 Given a role I<name> or L<Moose::Meta::Role> object, returns true if this role
831 =item B<< $metarole->add_role($role) >>
833 Given a L<Moose::Meta::Role> object, this adds the role to the list of
834 roles that the role does.
836 =item B<< $metarole->get_excluded_roles_list >>
838 Returns a list of role names which this role excludes.
840 =item B<< $metarole->excludes_role($role_name) >>
842 Given a role I<name>, returns true if this role excludes the named
845 =item B<< $metarole->add_excluded_roles(@role_names) >>
847 Given one or more role names, adds those roles to the list of excluded
854 The methods for dealing with a role's methods are all identical in API
855 and behavior to the same methods in L<Class::MOP::Class>.
859 =item B<< $metarole->method_metaclass >>
861 Returns the method metaclass name for the role. This defaults to
862 L<Moose::Meta::Role::Method>.
864 =item B<< $metarole->get_method($name) >>
866 =item B<< $metarole->has_method($name) >>
868 =item B<< $metarole->add_method( $name, $body ) >>
870 =item B<< $metarole->get_method_list >>
872 =item B<< $metarole->find_method_by_name($name) >>
874 These methods are all identical to the methods of the same name in
875 L<Class::MOP::Package>
881 As with methods, the methods for dealing with a role's attribute are
882 all identical in API and behavior to the same methods in
883 L<Class::MOP::Class>.
885 However, attributes stored in this class are I<not> stored as
886 objects. Rather, the attribute definition is stored as a hash
887 reference. When a role is composed into a class, this hash reference
888 is passed directly to the metaclass's C<add_attribute> method.
890 This is quite likely to change in the future.
894 =item B<< $metarole->get_attribute($attribute_name) >>
896 =item B<< $metarole->has_attribute($attribute_name) >>
898 =item B<< $metarole->get_attribute_list >>
900 =item B<< $metarole->add_attribute($name, %options) >>
902 =item B<< $metarole->remove_attribute($attribute_name) >>
906 =head2 Overload introspection and creation
908 The methods for dealing with a role's overloads are all identical in API
909 and behavior to the same methods in L<Class::MOP::Class>. Note that these are
910 not particularly useful (yet), because overloads do not participate in role
915 =item B<< $metarole->is_overloaded >>
917 =item B<< $metarole->get_overloaded_operator($op) >>
919 =item B<< $metarole->has_overloaded_operator($op) >>
921 =item B<< $metarole->get_overload_list >>
923 =item B<< $metarole->get_all_overloaded_operators >>
925 =item B<< $metarole->add_overloaded_operator($op, $impl) >>
927 =item B<< $metarole->remove_overloaded_operator($op) >>
931 =head2 Required methods
935 =item B<< $metarole->get_required_method_list >>
937 Returns the list of methods required by the role.
939 =item B<< $metarole->requires_method($name) >>
941 Returns true if the role requires the named method.
943 =item B<< $metarole->add_required_methods(@names) >>
945 Adds the named methods to the role's list of required methods.
947 =item B<< $metarole->remove_required_methods(@names) >>
949 Removes the named methods from the role's list of required methods.
951 =item B<< $metarole->add_conflicting_method(%params) >>
953 Instantiate the parameters as a L<Moose::Meta::Role::Method::Conflicting>
954 object, then add it to the required method list.
958 =head2 Method modifiers
960 These methods act like their counterparts in L<Class::MOP::Class> and
961 L<Moose::Meta::Class>.
963 However, method modifiers are simply stored internally, and are not
964 applied until the role itself is applied to a class.
968 =item B<< $metarole->add_after_method_modifier($method_name, $method) >>
970 =item B<< $metarole->add_around_method_modifier($method_name, $method) >>
972 =item B<< $metarole->add_before_method_modifier($method_name, $method) >>
974 =item B<< $metarole->add_override_method_modifier($method_name, $method) >>
976 These methods all add an appropriate modifier to the internal list of
979 =item B<< $metarole->has_after_method_modifiers >>
981 =item B<< $metarole->has_around_method_modifiers >>
983 =item B<< $metarole->has_before_method_modifiers >>
985 =item B<< $metarole->has_override_method_modifier >>
987 Return true if the role has any modifiers of the given type.
989 =item B<< $metarole->get_after_method_modifiers($method_name) >>
991 =item B<< $metarole->get_around_method_modifiers($method_name) >>
993 =item B<< $metarole->get_before_method_modifiers($method_name) >>
995 Given a method name, returns a list of the appropriate modifiers for
998 =item B<< $metarole->get_override_method_modifier($method_name) >>
1000 Given a method name, returns the override method modifier for that
1001 method, if it has one.
1005 =head2 Introspection
1009 =item B<< Moose::Meta::Role->meta >>
1011 This will return a L<Class::MOP::Class> instance for this class.
1017 See L<Moose/BUGS> for details on reporting bugs.