2 package Moose::Meta::Role;
8 use Scalar::Util 'blessed';
10 use Sub::Name 'subname';
11 use Devel::GlobalDestruction 'in_global_destruction';
13 our $VERSION = '0.84';
14 $VERSION = eval $VERSION;
15 our $AUTHORITY = 'cpan:STEVAN';
17 use Moose::Meta::Class;
18 use Moose::Meta::Role::Method;
19 use Moose::Meta::Role::Method::Required;
20 use Moose::Meta::Role::Method::Conflicting;
22 use base 'Class::MOP::Module';
24 ## ------------------------------------------------------------------
26 ## I normally don't do this, but I am doing
27 ## a whole bunch of meta-programmin in this
28 ## module, so it just makes sense. For a clearer
29 ## picture of what is going on in the next
30 ## several lines of code, look at the really
31 ## big comment at the end of this file (right
34 ## ------------------------------------------------------------------
36 my $META = __PACKAGE__->meta;
38 ## ------------------------------------------------------------------
42 # since roles are lazy, we hold all the attributes
43 # of the individual role in 'statis' until which
44 # time when it is applied to a class. This means
45 # keeping a lot of things in hash maps, so we are
46 # using a little of that meta-programmin' magic
47 # here an saving lots of extra typin. And since
48 # many of these attributes above require similar
49 # functionality to support them, so we again use
50 # the wonders of meta-programmin' to deliver a
51 # very compact solution to this normally verbose
57 name => 'excluded_roles_map',
58 attr_reader => 'get_excluded_roles_map' ,
60 add => 'add_excluded_roles',
61 get_keys => 'get_excluded_roles_list',
62 existence => 'excludes_role',
66 name => 'required_methods',
67 attr_reader => 'get_required_methods_map',
69 remove => 'remove_required_methods',
70 get_values => 'get_required_method_list',
71 existence => 'requires_method',
75 name => 'attribute_map',
76 attr_reader => 'get_attribute_map',
78 get => 'get_attribute',
79 get_keys => 'get_attribute_list',
80 existence => 'has_attribute',
81 remove => 'remove_attribute',
86 my $attr_reader = $action->{attr_reader};
87 my $methods = $action->{methods};
89 # create the attribute
90 $META->add_attribute($action->{name} => (
91 reader => $attr_reader,
95 # create some helper methods
96 $META->add_method($methods->{add} => sub {
97 my ($self, @values) = @_;
98 $self->$attr_reader->{$_} = undef foreach @values;
99 }) if exists $methods->{add};
101 $META->add_method($methods->{get_keys} => sub {
103 keys %{$self->$attr_reader};
104 }) if exists $methods->{get_keys};
106 $META->add_method($methods->{get_values} => sub {
108 values %{$self->$attr_reader};
109 }) if exists $methods->{get_values};
111 $META->add_method($methods->{get} => sub {
112 my ($self, $name) = @_;
113 $self->$attr_reader->{$name}
114 }) if exists $methods->{get};
116 $META->add_method($methods->{existence} => sub {
117 my ($self, $name) = @_;
118 exists $self->$attr_reader->{$name} ? 1 : 0;
119 }) if exists $methods->{existence};
121 $META->add_method($methods->{remove} => sub {
122 my ($self, @values) = @_;
123 delete $self->$attr_reader->{$_} foreach @values;
124 }) if exists $methods->{remove};
127 $META->add_attribute(
129 reader => 'method_metaclass',
130 default => 'Moose::Meta::Role::Method',
133 $META->add_attribute(
134 'required_method_metaclass',
135 reader => 'required_method_metaclass',
136 default => 'Moose::Meta::Role::Method::Required',
139 $META->add_attribute(
140 'conflicting_method_metaclass',
141 reader => 'conflicting_method_metaclass',
142 default => 'Moose::Meta::Role::Method::Conflicting',
145 ## some things don't always fit, so they go here ...
150 unless ( defined $name && $name ) {
152 Moose->throw_error("You must provide a name for the attribute");
155 if (scalar @_ == 1 && ref($_[0]) eq 'HASH') {
161 $self->get_attribute_map->{$name} = $attr_desc;
164 sub add_required_methods {
169 if (!blessed($method)) {
170 $method = $self->required_method_metaclass->new(
174 $self->get_required_methods_map->{$method->name} = $method;
178 sub add_conflicting_method {
182 if (@_ == 1 && blessed($_[0])) {
186 $method = $self->conflicting_method_metaclass->new(@_);
189 $self->add_required_methods($method);
192 ## ------------------------------------------------------------------
196 # the before/around/after method modifiers are
197 # stored by name, but there can be many methods
198 # then associated with that name. So again we have
199 # lots of similar functionality, so we can do some
200 # meta-programmin' and save some time.
203 foreach my $modifier_type (qw[ before around after ]) {
205 my $attr_reader = "get_${modifier_type}_method_modifiers_map";
207 # create the attribute ...
208 $META->add_attribute("${modifier_type}_method_modifiers" => (
209 reader => $attr_reader,
210 default => sub { {} }
213 # and some helper methods ...
214 $META->add_method("get_${modifier_type}_method_modifiers" => sub {
215 my ($self, $method_name) = @_;
216 #return () unless exists $self->$attr_reader->{$method_name};
217 my $mm = $self->$attr_reader->{$method_name};
221 $META->add_method("has_${modifier_type}_method_modifiers" => sub {
222 my ($self, $method_name) = @_;
224 # for now we assume that if it exists,..
225 # it has at least one modifier in it
226 (exists $self->$attr_reader->{$method_name}) ? 1 : 0;
229 $META->add_method("add_${modifier_type}_method_modifier" => sub {
230 my ($self, $method_name, $method) = @_;
232 $self->$attr_reader->{$method_name} = []
233 unless exists $self->$attr_reader->{$method_name};
235 my $modifiers = $self->$attr_reader->{$method_name};
238 # check to see that we aren't adding the
239 # same code twice. We err in favor of the
240 # first on here, this may not be as expected
241 foreach my $modifier (@{$modifiers}) {
242 return if $modifier == $method;
245 push @{$modifiers} => $method;
250 ## ------------------------------------------------------------------
251 ## override method mofidiers
253 $META->add_attribute('override_method_modifiers' => (
254 reader => 'get_override_method_modifiers_map',
255 default => sub { {} }
259 # these are a little different because there
260 # can only be one per name, whereas the other
261 # method modifiers can have multiples.
264 sub add_override_method_modifier {
265 my ($self, $method_name, $method) = @_;
266 (!$self->has_method($method_name))
267 || Moose->throw_error("Cannot add an override of method '$method_name' " .
268 "because there is a local version of '$method_name'");
269 $self->get_override_method_modifiers_map->{$method_name} = $method;
272 sub has_override_method_modifier {
273 my ($self, $method_name) = @_;
275 # for now we assume that if it exists,..
276 # it has at least one modifier in it
277 (exists $self->get_override_method_modifiers_map->{$method_name}) ? 1 : 0;
280 sub get_override_method_modifier {
281 my ($self, $method_name) = @_;
282 $self->get_override_method_modifiers_map->{$method_name};
285 ## general list accessor ...
287 sub get_method_modifier_list {
288 my ($self, $modifier_type) = @_;
289 my $accessor = "get_${modifier_type}_method_modifiers_map";
290 keys %{$self->$accessor};
293 sub reset_package_cache_flag { (shift)->{'_package_cache_flag'} = undef }
294 sub update_package_cache_flag {
296 $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name);
301 ## ------------------------------------------------------------------
304 $META->add_attribute('roles' => (
305 reader => 'get_roles',
306 default => sub { [] }
310 my ($self, $role) = @_;
311 (blessed($role) && $role->isa('Moose::Meta::Role'))
312 || Moose->throw_error("Roles must be instances of Moose::Meta::Role");
313 push @{$self->get_roles} => $role;
314 $self->reset_package_cache_flag;
317 sub calculate_all_roles {
323 $_->calculate_all_roles
324 } @{ $self->get_roles });
328 my ($self, $role_name) = @_;
330 || Moose->throw_error("You must supply a role name to look for");
331 # if we are it,.. then return true
332 return 1 if $role_name eq $self->name;
333 # otherwise.. check our children
334 foreach my $role (@{$self->get_roles}) {
335 return 1 if $role->does_role($role_name);
340 ## ------------------------------------------------------------------
346 my $current = Class::MOP::check_package_cache_flag($self->name);
348 if (defined $self->{'_package_cache_flag'} && $self->{'_package_cache_flag'} == $current) {
349 return $self->{'methods'} ||= {};
352 $self->{_package_cache_flag} = $current;
354 my $map = $self->{'methods'} ||= {};
356 my $role_name = $self->name;
357 my $method_metaclass = $self->method_metaclass;
359 my $all_code = $self->get_all_package_symbols('CODE');
361 foreach my $symbol (keys %{ $all_code }) {
362 my $code = $all_code->{$symbol};
364 next if exists $map->{$symbol} &&
365 defined $map->{$symbol} &&
366 $map->{$symbol}->body == $code;
368 my ($pkg, $name) = Class::MOP::get_code_info($code);
369 my $meta = Class::MOP::class_of($pkg);
371 if ($meta && $meta->isa('Moose::Meta::Role')) {
372 my $role = $meta->name;
373 next unless $self->does_role($role);
377 # in 5.10 constant.pm the constants show up
378 # as being in the right package, but in pre-5.10
379 # they show up as constant::__ANON__ so we
380 # make an exception here to be sure that things
381 # work as expected in both.
383 unless ($pkg eq 'constant' && $name eq '__ANON__') {
384 next if ($pkg || '') ne $role_name ||
385 (($name || '') ne '__ANON__' && ($pkg || '') ne $role_name);
389 $map->{$symbol} = $method_metaclass->wrap(
391 package_name => $role_name,
400 my ($self, $name) = @_;
401 $self->get_method_map->{$name};
405 my ($self, $name) = @_;
406 exists $self->get_method_map->{$name} ? 1 : 0
409 # FIXME this is copy-pasted from Class::MOP::Class
410 # refactor to inherit from some common base
411 sub wrap_method_body {
412 my ( $self, %args ) = @_;
414 ('CODE' eq ref $args{body})
415 || Moose->throw_error("Your code block must be a CODE reference");
417 $self->method_metaclass->wrap(
418 package_name => $self->name,
424 my ($self, $method_name, $method) = @_;
425 (defined $method_name && $method_name)
426 || Moose->throw_error("You must define a method name");
429 if (blessed($method)) {
430 $body = $method->body;
431 if ($method->package_name ne $self->name) {
432 $method = $method->clone(
433 package_name => $self->name,
435 ) if $method->can('clone');
440 $method = $self->wrap_method_body( body => $body, name => $method_name );
443 $method->attach_to_class($self);
445 $self->get_method_map->{$method_name} = $method;
447 my $full_method_name = ($self->name . '::' . $method_name);
448 $self->add_package_symbol(
449 { sigil => '&', type => 'CODE', name => $method_name },
450 subname($full_method_name => $body)
453 $self->update_package_cache_flag; # still valid, since we just added the method to the map, and if it was invalid before that then get_method_map updated it
456 sub find_method_by_name { (shift)->get_method(@_) }
458 sub get_method_list {
460 grep { !/^meta$/ } keys %{$self->get_method_map};
464 Carp::cluck("The alias_method method is deprecated. Use add_method instead.\n");
468 $self->add_method(@_);
471 ## ------------------------------------------------------------------
473 ## ------------------------------------------------------------------
476 my ($self, $other, @args) = @_;
479 || Moose->throw_error("You must pass in an blessed instance");
481 if ($other->isa('Moose::Meta::Role')) {
482 require Moose::Meta::Role::Application::ToRole;
483 return Moose::Meta::Role::Application::ToRole->new(@args)->apply($self, $other);
485 elsif ($other->isa('Moose::Meta::Class')) {
486 require Moose::Meta::Role::Application::ToClass;
487 return Moose::Meta::Role::Application::ToClass->new(@args)->apply($self, $other);
490 require Moose::Meta::Role::Application::ToInstance;
491 return Moose::Meta::Role::Application::ToInstance->new(@args)->apply($self, $other);
496 my ($class, @role_specs) = @_;
498 require Moose::Meta::Role::Application::RoleSummation;
499 require Moose::Meta::Role::Composite;
501 my (@roles, %role_params);
502 while (@role_specs) {
503 my ($role_name, $params) = @{ splice @role_specs, 0, 1 };
504 my $requested_role = Class::MOP::class_of($role_name);
506 my $actual_role = $requested_role->_role_for_combination($params);
507 push @roles => $actual_role;
509 next unless defined $params;
510 $role_params{$actual_role->name} = $params;
513 my $c = Moose::Meta::Role::Composite->new(roles => \@roles);
514 Moose::Meta::Role::Application::RoleSummation->new(
515 role_params => \%role_params
521 sub _role_for_combination {
522 my ($self, $params) = @_;
527 my ( $role, $package_name, %options ) = @_;
529 $options{package} = $package_name;
531 (ref $options{attributes} eq 'HASH')
532 || confess "You must pass a HASH ref of attributes"
533 if exists $options{attributes};
535 (ref $options{methods} eq 'HASH')
536 || confess "You must pass a HASH ref of methods"
537 if exists $options{methods};
539 my (%initialize_options) = %options;
540 delete @initialize_options{qw(
548 my $meta = $role->initialize( $package_name => %initialize_options );
550 $meta->_instantiate_module( $options{version}, $options{authority} );
553 $meta->add_method('meta' => sub {
554 $role->initialize(ref($_[0]) || $_[0]);
557 if (exists $options{attributes}) {
558 foreach my $attribute_name (keys %{$options{attributes}}) {
559 my $attr = $options{attributes}->{$attribute_name};
560 $meta->add_attribute($attribute_name => $attr);
564 if (exists $options{methods}) {
565 foreach my $method_name (keys %{$options{methods}}) {
566 $meta->add_method($method_name, $options{methods}->{$method_name});
570 Class::MOP::weaken_metaclass($meta->name)
571 if $meta->is_anon_role;
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 my $package_name = $ANON_ROLE_PREFIX . ++$ANON_ROLE_SERIAL;
602 return $role->create($package_name, %options);
606 # this will only get called for
607 # anon-roles, all other calls
608 # are assumed to occur during
609 # global destruction and so don't
610 # really need to be handled explicitly
614 return if in_global_destruction(); # it'll happen soon anyway and this just makes things more complicated
616 no warnings 'uninitialized';
617 return unless $self->name =~ /^$ANON_ROLE_PREFIX/;
619 # XXX: is this necessary for us? I don't understand what it's doing
622 # Moose does a weird thing where it replaces the metaclass for
623 # class when fixing metaclass incompatibility. In that case,
624 # we don't want to clean out the namespace now. We can detect
625 # that because Moose will explicitly update the singleton
626 # cache in Class::MOP.
627 #my $current_meta = Class::MOP::get_metaclass_by_name($self->name);
628 #return if $current_meta ne $self;
630 my ($serial_id) = ($self->name =~ /^$ANON_ROLE_PREFIX(\d+)/);
632 foreach my $key (keys %{$ANON_ROLE_PREFIX . $serial_id}) {
633 delete ${$ANON_ROLE_PREFIX . $serial_id}{$key};
635 delete ${'main::' . $ANON_ROLE_PREFIX}{$serial_id . '::'};
639 #####################################################################
641 ## This is Moose::Meta::Role as defined by Moose (plus the use of
642 ## MooseX::AttributeHelpers module). It is here as a reference to
643 ## make it easier to see what is happening above with all the meta
645 #####################################################################
648 # metaclass => 'Collection::Array',
649 # reader => 'get_roles',
650 # isa => 'ArrayRef[Moose::Meta::Role]',
651 # default => sub { [] },
653 # 'push' => 'add_role',
657 # has 'excluded_roles_map' => (
658 # metaclass => 'Collection::Hash',
659 # reader => 'get_excluded_roles_map',
660 # isa => 'HashRef[Str]',
662 # # Not exactly set, cause it sets multiple
663 # 'set' => 'add_excluded_roles',
664 # 'keys' => 'get_excluded_roles_list',
665 # 'exists' => 'excludes_role',
669 # has 'attribute_map' => (
670 # metaclass => 'Collection::Hash',
671 # reader => 'get_attribute_map',
672 # isa => 'HashRef[Str]',
674 # # 'set' => 'add_attribute' # has some special crap in it
675 # 'get' => 'get_attribute',
676 # 'keys' => 'get_attribute_list',
677 # 'exists' => 'has_attribute',
678 # # Not exactly delete, cause it sets multiple
679 # 'delete' => 'remove_attribute',
683 # has 'required_methods' => (
684 # metaclass => 'Collection::Hash',
685 # reader => 'get_required_methods_map',
686 # isa => 'HashRef[Moose::Meta::Role::Method::Required]',
688 # # not exactly set, or delete since it works for multiple
689 # 'set' => 'add_required_methods',
690 # 'delete' => 'remove_required_methods',
691 # 'keys' => 'get_required_method_list',
692 # 'exists' => 'requires_method',
696 # # the before, around and after modifiers are
697 # # HASH keyed by method-name, with ARRAY of
698 # # CODE refs to apply in that order
700 # has 'before_method_modifiers' => (
701 # metaclass => 'Collection::Hash',
702 # reader => 'get_before_method_modifiers_map',
703 # isa => 'HashRef[ArrayRef[CodeRef]]',
705 # 'keys' => 'get_before_method_modifiers',
706 # 'exists' => 'has_before_method_modifiers',
707 # # This actually makes sure there is an
708 # # ARRAY at the given key, and pushed onto
709 # # it. It also checks for duplicates as well
710 # # 'add' => 'add_before_method_modifier'
714 # has 'after_method_modifiers' => (
715 # metaclass => 'Collection::Hash',
716 # reader =>'get_after_method_modifiers_map',
717 # isa => 'HashRef[ArrayRef[CodeRef]]',
719 # 'keys' => 'get_after_method_modifiers',
720 # 'exists' => 'has_after_method_modifiers',
721 # # This actually makes sure there is an
722 # # ARRAY at the given key, and pushed onto
723 # # it. It also checks for duplicates as well
724 # # 'add' => 'add_after_method_modifier'
728 # has 'around_method_modifiers' => (
729 # metaclass => 'Collection::Hash',
730 # reader =>'get_around_method_modifiers_map',
731 # isa => 'HashRef[ArrayRef[CodeRef]]',
733 # 'keys' => 'get_around_method_modifiers',
734 # 'exists' => 'has_around_method_modifiers',
735 # # This actually makes sure there is an
736 # # ARRAY at the given key, and pushed onto
737 # # it. It also checks for duplicates as well
738 # # 'add' => 'add_around_method_modifier'
742 # # override is similar to the other modifiers
743 # # except that it is not an ARRAY of code refs
744 # # but instead just a single name->code mapping
746 # has 'override_method_modifiers' => (
747 # metaclass => 'Collection::Hash',
748 # reader =>'get_override_method_modifiers_map',
749 # isa => 'HashRef[CodeRef]',
751 # 'keys' => 'get_override_method_modifier',
752 # 'exists' => 'has_override_method_modifier',
753 # 'add' => 'add_override_method_modifier', # checks for local method ..
757 #####################################################################
768 Moose::Meta::Role - The Moose Role metaclass
772 This class is a subclass of L<Class::MOP::Module> that provides
773 additional Moose-specific functionality.
775 It's API looks a lot like L<Moose::Meta::Class>, but internally it
776 implements many things differently. This may change in the future.
780 C<Moose::Meta::Role> is a subclass of L<Class::MOP::Module>.
788 =item B<< Moose::Meta::Role->initialize($role_name) >>
790 This method creates a new role object with the provided name.
792 =item B<< Moose::Meta::Role->combine( [ $role => { ... } ], [ $role ], ... ) >>
794 This method accepts a list of array references. Each array reference
795 should contain a role name as its first element. The second element is
796 an optional hash reference. The hash reference can contain C<exclude>
797 and C<alias> keys to control how methods are composed from the role.
799 The return value is a new L<Moose::Meta::Role::Composite> that
800 represents the combined roles.
802 =item B<< Moose::Meta::Role->create($name, %options) >>
804 This method is identical to the L<Moose::Meta::Class> C<create>
807 =item B<< Moose::Meta::Role->create_anon_role >>
809 This method is identical to the L<Moose::Meta::Class>
810 C<create_anon_class> method.
812 =item B<< $metarole->is_anon_role >>
814 Returns true if the role is an anonymous role.
818 =head2 Role application
822 =item B<< $metarole->apply( $thing, @options ) >>
824 This method applies a role to the given C<$thing>. That can be another
825 L<Moose::Meta::Role>, object, a L<Moose::Meta::Class> object, or a
826 (non-meta) object instance.
828 The options are passed directly to the constructor for the appropriate
829 L<Moose::Meta::Role::Application> subclass.
831 Note that this will apply the role even if the C<$thing> in question already
832 C<does> this role. L<Moose::Util/does_role> is a convenient wrapper for
833 finding out if role application is necessary.
837 =head2 Roles and other roles
841 =item B<< $metarole->get_roles >>
843 This returns an array reference of roles which this role does. This
844 list may include duplicates.
846 =item B<< $metarole->calculate_all_roles >>
848 This returns a I<unique> list of all roles that this role does, and
849 all the roles that its roles do.
851 =item B<< $metarole->does_role($role_name) >>
853 Given a role I<name>, returns true if this role does the given
856 =item B<< $metarole->add_role($role) >>
858 Given a L<Moose::Meta::Role> object, this adds the role to the list of
859 roles that the role does.
861 =item B<< $metarole->get_excluded_roles_list >>
863 Returns a list of role names which this role excludes.
865 =item B<< $metarole->excludes_role($role_name) >>
867 Given a role I<name>, returns true if this role excludes the named
870 =item B<< $metarole->add_excluded_roles(@role_names) >>
872 Given one or more role names, adds those roles to the list of excluded
879 The methods for dealing with a role's methods are all identical in API
880 and behavior to the same methods in L<Class::MOP::Class>.
884 =item B<< $metarole->method_metaclass >>
886 Returns the method metaclass name for the role. This defaults to
887 L<Moose::Meta::Role::Method>.
889 =item B<< $metarole->get_method($name) >>
891 =item B<< $metarole->has_method($name) >>
893 =item B<< $metarole->add_method( $name, $body ) >>
895 =item B<< $metarole->get_method_list >>
897 =item B<< $metarole->get_method_map >>
899 =item B<< $metarole->find_method_by_name($name) >>
901 These methods are all identical to the methods of the same name in
908 As with methods, the methods for dealing with a role's attribute are
909 all identical in API and behavior to the same methods in
910 L<Class::MOP::Class>.
912 However, attributes stored in this class are I<not> stored as
913 objects. Rather, the attribute definition is stored as a hash
914 reference. When a role is composed into a class, this hash reference
915 is passed directly to the metaclass's C<add_attribute> method.
917 This is quite likely to change in the future.
921 =item B<< $metarole->get_attribute($attribute_name) >>
923 =item B<< $metarole->has_attribute($attribute_name) >>
925 =item B<< $metarole->get_attribute_map >>
927 =item B<< $metarole->get_attribute_list >>
929 =item B<< $metarole->add_attribute($name, %options) >>
931 =item B<< $metarole->remove_attribute($attribute_name) >>
935 =head2 Required methods
939 =item B<< $metarole->get_required_method_list >>
941 Returns the list of methods required by the role.
943 =item B<< $metarole->requires_method($name) >>
945 Returns true if the role requires the named method.
947 =item B<< $metarole->add_required_methods(@names) >>
949 Adds the named methods to the role's list of required methods.
951 =item B<< $metarole->remove_required_methods(@names) >>
953 Removes the named methods from the role's list of required methods.
955 =item B<< $metarole->add_conflicting_method(%params) >>
957 Instantiate the parameters as a L<Moose::Meta::Role::Method::Conflicting>
958 object, then add it to the required method list.
962 =head2 Method modifiers
964 These methods act like their counterparts in L<Class::Mop::Class> and
965 L<Moose::Meta::Class>.
967 However, method modifiers are simply stored internally, and are not
968 applied until the role itself is applied to a class.
972 =item B<< $metarole->add_after_method_modifier($method_name, $method) >>
974 =item B<< $metarole->add_around_method_modifier($method_name, $method) >>
976 =item B<< $metarole->add_before_method_modifier($method_name, $method) >>
978 =item B<< $metarole->add_override_method_modifier($method_name, $method) >>
980 These methods all add an appropriate modifier to the internal list of
983 =item B<< $metarole->has_after_method_modifiers >>
985 =item B<< $metarole->has_around_method_modifiers >>
987 =item B<< $metarole->has_before_method_modifiers >>
989 =item B<< $metarole->has_override_method_modifier >>
991 Return true if the role has any modifiers of the given type.
993 =item B<< $metarole->get_after_method_modifiers($method_name) >>
995 =item B<< $metarole->get_around_method_modifiers($method_name) >>
997 =item B<< $metarole->get_before_method_modifiers($method_name) >>
999 Given a method name, returns a list of the appropriate modifiers for
1002 =item B<< $metarole->get_override_method_modifier($method_name) >>
1004 Given a method name, returns the override method modifier for that
1005 method, if it has one.
1009 =head2 Introspection
1013 =item B<< Moose::Meta::Role->meta >>
1015 This will return a L<Class::MOP::Class> instance for this class.
1021 All complex software has bugs lurking in it, and this module is no
1022 exception. If you find a bug please either email me, or add the bug
1027 Stevan Little E<lt>stevan@iinteractive.comE<gt>
1029 =head1 COPYRIGHT AND LICENSE
1031 Copyright 2006-2009 by Infinity Interactive, Inc.
1033 L<http://www.iinteractive.com>
1035 This library is free software; you can redistribute it and/or modify
1036 it under the same terms as Perl itself.