refactor in progress, beware (still passing all my tests though :P)
[gitmo/Moose.git] / lib / Moose / Meta / Role.pm
1
2 package Moose::Meta::Role;
3
4 use strict;
5 use warnings;
6 use metaclass;
7
8 use Sub::Name    'subname';
9 use Carp         'confess';
10 use Scalar::Util 'blessed', 'reftype';
11
12 our $VERSION   = '0.12';
13 our $AUTHORITY = 'cpan:STEVAN';
14
15 use Moose::Meta::Class;
16 use Moose::Meta::Role::Method;
17 use Moose::Meta::Role::Method::Required;
18
19 use base 'Class::MOP::Module';
20
21 ## ------------------------------------------------------------------
22 ## NOTE:
23 ## I normally don't do this, but I am doing
24 ## a whole bunch of meta-programmin in this
25 ## module, so it just makes sense. For a clearer
26 ## picture of what is going on in the next 
27 ## several lines of code, look at the really 
28 ## big comment at the end of this file (right
29 ## before the POD).
30 ## - SL
31 ## ------------------------------------------------------------------
32
33 my $META = __PACKAGE__->meta;
34
35 ## ------------------------------------------------------------------
36 ## attributes ...
37
38 # NOTE:
39 # since roles are lazy, we hold all the attributes
40 # of the individual role in 'statis' until which
41 # time when it is applied to a class. This means
42 # keeping a lot of things in hash maps, so we are
43 # using a little of that meta-programmin' magic
44 # here an saving lots of extra typin. And since 
45 # many of these attributes above require similar
46 # functionality to support them, so we again use
47 # the wonders of meta-programmin' to deliver a
48 # very compact solution to this normally verbose
49 # problem.
50 # - SL
51
52 foreach my $action (
53     {
54         name        => 'excluded_roles_map',
55         attr_reader => 'get_excluded_roles_map' ,
56         methods     => {
57             add       => 'add_excluded_roles',
58             get_list  => 'get_excluded_roles_list',
59             existence => 'excludes_role',
60         }
61     },
62     {
63         name        => 'required_methods',
64         attr_reader => 'get_required_methods_map',
65         methods     => {
66             add       => 'add_required_methods',
67             remove    => 'remove_required_methods',
68             get_list  => 'get_required_method_list',
69             existence => 'requires_method',
70         }
71     },
72     {
73         name        => 'attribute_map',
74         attr_reader => 'get_attribute_map',
75         methods     => {
76             get       => 'get_attribute',
77             get_list  => 'get_attribute_list',
78             existence => 'has_attribute',
79             remove    => 'remove_attribute',
80         }
81     }
82 ) {
83
84     my $attr_reader = $action->{attr_reader};
85     my $methods     = $action->{methods};
86
87     # create the attribute
88     $META->add_attribute($action->{name} => (
89         reader  => $attr_reader,
90         default => sub { {} }
91     ));
92
93     # create some helper methods
94     $META->add_method($methods->{add} => sub {
95         my ($self, @values) = @_;
96         $self->$attr_reader->{$_} = undef foreach @values;
97     }) if exists $methods->{add};
98
99     $META->add_method($methods->{get_list} => sub {
100         my ($self) = @_;
101         keys %{$self->$attr_reader};
102     }) if exists $methods->{get_list};
103
104     $META->add_method($methods->{get} => sub {
105         my ($self, $name) = @_;
106         $self->$attr_reader->{$name}
107     }) if exists $methods->{get};
108
109     $META->add_method($methods->{existence} => sub {
110         my ($self, $name) = @_;
111         exists $self->$attr_reader->{$name} ? 1 : 0;
112     }) if exists $methods->{existence};
113
114     $META->add_method($methods->{remove} => sub {
115         my ($self, @values) = @_;
116         delete $self->$attr_reader->{$_} foreach @values;
117     }) if exists $methods->{remove};
118 }
119
120 ## some things don't always fit, so they go here ...
121
122 sub add_attribute {
123     my $self = shift;
124     my $name = shift;
125     my $attr_desc;
126     if (scalar @_ == 1 && ref($_[0]) eq 'HASH') {
127         $attr_desc = $_[0];
128     }
129     else {
130         $attr_desc = { @_ };
131     }
132     $self->get_attribute_map->{$name} = $attr_desc;
133 }
134
135 sub _clean_up_required_methods {
136     my $self = shift;
137     foreach my $method ($self->get_required_method_list) {
138         $self->remove_required_methods($method)
139             if $self->has_method($method);
140     }
141 }
142
143 ## ------------------------------------------------------------------
144 ## method modifiers
145
146 # NOTE:
147 # the before/around/after method modifiers are
148 # stored by name, but there can be many methods
149 # then associated with that name. So again we have
150 # lots of similar functionality, so we can do some
151 # meta-programmin' and save some time.
152 # - SL
153
154 foreach my $modifier_type (qw[ before around after ]) {
155
156     my $attr_reader = "get_${modifier_type}_method_modifiers_map";
157     
158     # create the attribute ...
159     $META->add_attribute("${modifier_type}_method_modifiers" => (
160         reader  => $attr_reader,
161         default => sub { {} }
162     ));  
163
164     # and some helper methods ...
165     $META->add_method("get_${modifier_type}_method_modifiers" => sub {
166         my ($self, $method_name) = @_;
167         #return () unless exists $self->$attr_reader->{$method_name};
168         @{$self->$attr_reader->{$method_name}};
169     });
170
171     $META->add_method("has_${modifier_type}_method_modifiers" => sub {
172         my ($self, $method_name) = @_;
173         # NOTE:
174         # for now we assume that if it exists,..
175         # it has at least one modifier in it
176         (exists $self->$attr_reader->{$method_name}) ? 1 : 0;
177     });
178
179     $META->add_method("add_${modifier_type}_method_modifier" => sub {
180         my ($self, $method_name, $method) = @_;
181
182         $self->$attr_reader->{$method_name} = []
183             unless exists $self->$attr_reader->{$method_name};
184
185         my $modifiers = $self->$attr_reader->{$method_name};
186
187         # NOTE:
188         # check to see that we aren't adding the
189         # same code twice. We err in favor of the
190         # first on here, this may not be as expected
191         foreach my $modifier (@{$modifiers}) {
192             return if $modifier == $method;
193         }
194
195         push @{$modifiers} => $method;
196     });
197
198 }
199
200 ## ------------------------------------------------------------------
201 ## override method mofidiers
202
203 $META->add_attribute('override_method_modifiers' => (
204     reader  => 'get_override_method_modifiers_map',
205     default => sub { {} }
206 ));
207
208 # NOTE:
209 # these are a little different because there
210 # can only be one per name, whereas the other
211 # method modifiers can have multiples.
212 # - SL
213
214 sub add_override_method_modifier {
215     my ($self, $method_name, $method) = @_;
216     (!$self->has_method($method_name))
217         || confess "Cannot add an override of method '$method_name' " .
218                    "because there is a local version of '$method_name'";
219     $self->get_override_method_modifiers_map->{$method_name} = $method;
220 }
221
222 sub has_override_method_modifier {
223     my ($self, $method_name) = @_;
224     # NOTE:
225     # for now we assume that if it exists,..
226     # it has at least one modifier in it
227     (exists $self->get_override_method_modifiers_map->{$method_name}) ? 1 : 0;
228 }
229
230 sub get_override_method_modifier {
231     my ($self, $method_name) = @_;
232     $self->get_override_method_modifiers_map->{$method_name};
233 }
234
235 ## general list accessor ...
236
237 sub get_method_modifier_list {
238     my ($self, $modifier_type) = @_;
239     my $accessor = "get_${modifier_type}_method_modifiers_map";
240     keys %{$self->$accessor};
241 }
242
243 ## ------------------------------------------------------------------
244 ## subroles
245
246 __PACKAGE__->meta->add_attribute('roles' => (
247     reader  => 'get_roles',
248     default => sub { [] }
249 ));
250
251 sub add_role {
252     my ($self, $role) = @_;
253     (blessed($role) && $role->isa('Moose::Meta::Role'))
254         || confess "Roles must be instances of Moose::Meta::Role";
255     push @{$self->get_roles} => $role;
256 }
257
258 sub calculate_all_roles {
259     my $self = shift;
260     my %seen;
261     grep {
262         !$seen{$_->name}++
263     } ($self, map {
264                   $_->calculate_all_roles
265               } @{ $self->get_roles });
266 }
267
268 sub does_role {
269     my ($self, $role_name) = @_;
270     (defined $role_name)
271         || confess "You must supply a role name to look for";
272     # if we are it,.. then return true
273     return 1 if $role_name eq $self->name;
274     # otherwise.. check our children
275     foreach my $role (@{$self->get_roles}) {
276         return 1 if $role->does_role($role_name);
277     }
278     return 0;
279 }
280
281 ## ------------------------------------------------------------------
282 ## methods
283
284 sub method_metaclass { 'Moose::Meta::Role::Method' }
285
286 sub get_method_map {
287     my $self = shift;
288     my $map  = {};
289
290     my $role_name        = $self->name;
291     my $method_metaclass = $self->method_metaclass;
292
293     foreach my $symbol ($self->list_all_package_symbols('CODE')) {
294
295         my $code = $self->get_package_symbol('&' . $symbol);
296
297         my ($pkg, $name) = Class::MOP::get_code_info($code);
298
299         if ($pkg->can('meta')
300             # NOTE:
301             # we don't know what ->meta we are calling
302             # here, so we need to be careful cause it
303             # just might blow up at us, or just complain
304             # loudly (in the case of Curses.pm) so we
305             # just be a little overly cautious here.
306             # - SL
307             && eval { no warnings; blessed($pkg->meta) }
308             && $pkg->meta->isa('Moose::Meta::Role')) {
309             my $role = $pkg->meta->name;
310             next unless $self->does_role($role);
311         }
312         else {
313             next if ($pkg  || '') ne $role_name &&
314                     ($name || '') ne '__ANON__';
315         }
316
317         $map->{$symbol} = $method_metaclass->wrap($code);
318     }
319
320     return $map;    
321 }
322
323 sub get_method { 
324     my ($self, $name) = @_;
325     $self->get_method_map->{$name}
326 }
327
328 sub has_method {
329     my ($self, $name) = @_;
330     exists $self->get_method_map->{$name} ? 1 : 0
331 }
332
333 sub find_method_by_name { (shift)->get_method(@_) }
334
335 sub get_method_list {
336     my $self = shift;
337     grep { !/^meta$/ } keys %{$self->get_method_map};
338 }
339
340 sub alias_method {
341     my ($self, $method_name, $method) = @_;
342     (defined $method_name && $method_name)
343         || confess "You must define a method name";
344
345     my $body = (blessed($method) ? $method->body : $method);
346     ('CODE' eq (reftype($body) || ''))
347         || confess "Your code block must be a CODE reference";
348
349     $self->add_package_symbol("&${method_name}" => $body);
350 }
351
352 sub reset_package_cache_flag  { () }
353 sub update_package_cache_flag { () }
354
355 ## ------------------------------------------------------------------
356 ## role construction
357 ## ------------------------------------------------------------------
358
359 my $anon_counter = 0;
360
361 sub apply {
362     my ($self, $other) = @_;
363
364     unless ($other->isa('Moose::Meta::Class') || $other->isa('Moose::Meta::Role')) {
365
366         # Runtime Role mixins
367
368         # FIXME:
369         # We really should do this better, and
370         # cache the results of our efforts so
371         # that we don't need to repeat them.
372
373         my $pkg_name = __PACKAGE__ . "::__RUNTIME_ROLE_ANON_CLASS__::" . $anon_counter++;
374         eval "package " . $pkg_name . "; our \$VERSION = '0.00';";
375         die $@ if $@;
376
377         my $object = $other;
378
379         $other = Moose::Meta::Class->initialize($pkg_name);
380         $other->superclasses(blessed($object));
381
382         bless $object => $pkg_name;
383     }
384
385     $self->_check_excluded_roles($other);
386     $self->_check_required_methods($other);
387
388     $self->_apply_attributes($other);
389     $self->_apply_methods($other);
390
391     # NOTE:
392     # we need a clear cache flag too ...
393     $other->reset_package_cache_flag;
394
395     $self->_apply_override_method_modifiers($other);
396     
397     $self->_apply_before_method_modifiers($other);
398     $self->_apply_around_method_modifiers($other);
399     $self->_apply_after_method_modifiers($other);
400
401     $other->add_role($self);
402 }
403
404 sub combine {
405     my ($class, @roles) = @_;
406     
407     require Moose::Meta::Role::Application::RoleSummation;
408     require Moose::Meta::Role::Composite;    
409     
410     my $c = Moose::Meta::Role::Composite->new(roles => \@roles);
411     Moose::Meta::Role::Application::RoleSummation->new->apply($c);
412     return $c;
413 }
414
415 ## ------------------------------------------------------------------
416
417 ## applying a role to a class ...
418
419 sub _check_excluded_roles {
420     my ($self, $other) = @_;
421     if ($other->excludes_role($self->name)) {
422         confess "Conflict detected: " . $other->name . " excludes role '" . $self->name . "'";
423     }
424     foreach my $excluded_role_name ($self->get_excluded_roles_list) {
425         if ($other->does_role($excluded_role_name)) {
426             confess "The class " . $other->name . " does the excluded role '$excluded_role_name'";
427         }
428         else {
429             if ($other->isa('Moose::Meta::Role')) {
430                 $other->add_excluded_roles($excluded_role_name);
431             }
432             # else -> ignore it :)
433         }
434     }
435 }
436
437 sub _check_required_methods {
438     my ($self, $other) = @_;
439     # NOTE:
440     # we might need to move this down below the
441     # the attributes so that we can require any
442     # attribute accessors. However I am thinking
443     # that maybe those are somehow exempt from
444     # the require methods stuff.
445     foreach my $required_method_name ($self->get_required_method_list) {
446
447         unless ($other->find_method_by_name($required_method_name)) {
448             if ($other->isa('Moose::Meta::Role')) {
449                 $other->add_required_methods($required_method_name);
450             }
451             else {
452                 confess "'" . $self->name . "' requires the method '$required_method_name' " .
453                         "to be implemented by '" . $other->name . "'";
454             }
455         }
456         else {
457             # NOTE:
458             # we need to make sure that the method is
459             # not a method modifier, because those do
460             # not satisfy the requirements ...
461             my $method = $other->find_method_by_name($required_method_name);
462
463             # check if it is a generated accessor ...
464             (!$method->isa('Class::MOP::Method::Accessor'))
465                 || confess "'" . $self->name . "' requires the method '$required_method_name' " .
466                            "to be implemented by '" . $other->name . "', the method is only an attribute accessor";
467
468             # NOTE:
469             # All other tests here have been removed, they were tests
470             # for overriden methods and before/after/around modifiers.
471             # But we realized that for classes any overriden or modified
472             # methods would be backed by a real method of that name
473             # (and therefore meet the requirement). And for roles, the
474             # overriden and modified methods are "in statis" and so would
475             # not show up in this test anyway (and as a side-effect they
476             # would not fufill the requirement, which is exactly what we
477             # want them to do anyway).
478             # - SL
479         }
480     }
481 }
482
483 sub _apply_attributes {
484     my ($self, $other) = @_;
485     foreach my $attribute_name ($self->get_attribute_list) {
486         # it if it has one already
487         if ($other->has_attribute($attribute_name) &&
488             # make sure we haven't seen this one already too
489             $other->get_attribute($attribute_name) != $self->get_attribute($attribute_name)) {
490             # see if we are being composed
491             # into a role or not
492             if ($other->isa('Moose::Meta::Role')) {
493                 # all attribute conflicts between roles
494                 # result in an immediate fatal error
495                 confess "Role '" . $self->name . "' has encountered an attribute conflict " .
496                         "during composition. This is fatal error and cannot be disambiguated.";
497             }
498             else {
499                 # but if this is a class, we
500                 # can safely skip adding the
501                 # attribute to the class
502                 next;
503             }
504         }
505         else {
506             # NOTE:
507             # this is kinda ugly ...
508             if ($other->isa('Moose::Meta::Class')) {
509                 $other->_process_attribute(
510                     $attribute_name,
511                     %{$self->get_attribute($attribute_name)}
512                 );
513             }
514             else {
515                 $other->add_attribute(
516                     $attribute_name,
517                     $self->get_attribute($attribute_name)
518                 );
519             }
520         }
521     }
522 }
523
524 sub _apply_methods {
525     my ($self, $other) = @_;
526     foreach my $method_name ($self->get_method_list) {
527         # it if it has one already
528         if ($other->has_method($method_name) &&
529             # and if they are not the same thing ...
530             $other->get_method($method_name)->body != $self->get_method($method_name)->body) {
531             # see if we are composing into a role
532             if ($other->isa('Moose::Meta::Role')) {
533                 # method conflicts between roles result
534                 # in the method becoming a requirement
535                 $other->add_required_methods($method_name);
536                 # NOTE:
537                 # we have to remove the method from our
538                 # role, if this is being called from combine()
539                 # which means the meta is an anon class
540                 # this *may* cause problems later, but it
541                 # is probably fairly safe to assume that
542                 # anon classes will only be used internally
543                 # or by people who know what they are doing
544                 $other->Moose::Meta::Class::remove_method($method_name)
545                     if $other->name =~ /__COMPOSITE_ROLE_SANDBOX__/;
546             }
547             else {
548                 next;
549             }
550         }
551         else {
552             # add it, although it could be overriden
553             $other->alias_method(
554                 $method_name,
555                 $self->get_method($method_name)
556             );
557         }
558     }
559 }
560
561 sub _apply_override_method_modifiers {
562     my ($self, $other) = @_;
563     foreach my $method_name ($self->get_method_modifier_list('override')) {
564         # it if it has one already then ...
565         if ($other->has_method($method_name)) {
566             # if it is being composed into another role
567             # we have a conflict here, because you cannot
568             # combine an overriden method with a locally
569             # defined one
570             if ($other->isa('Moose::Meta::Role')) {
571                 confess "Role '" . $self->name . "' has encountered an 'override' method conflict " .
572                         "during composition (A local method of the same name as been found). This " .
573                         "is fatal error.";
574             }
575             else {
576                 # if it is a class, then we
577                 # just ignore this here ...
578                 next;
579             }
580         }
581         else {
582             # if no local method is found, then we
583             # must check if we are a role or class
584             if ($other->isa('Moose::Meta::Role')) {
585                 # if we are a role, we need to make sure
586                 # we dont have a conflict with the role
587                 # we are composing into
588                 if ($other->has_override_method_modifier($method_name) &&
589                     $other->get_override_method_modifier($method_name) != $self->get_override_method_modifier($method_name)) {
590                     confess "Role '" . $self->name . "' has encountered an 'override' method conflict " .
591                             "during composition (Two 'override' methods of the same name encountered). " .
592                             "This is fatal error.";
593                 }
594                 else {
595                     # if there is no conflict,
596                     # just add it to the role
597                     $other->add_override_method_modifier(
598                         $method_name,
599                         $self->get_override_method_modifier($method_name)
600                     );
601                 }
602             }
603             else {
604                 # if this is not a role, then we need to
605                 # find the original package of the method
606                 # so that we can tell the class were to
607                 # find the right super() method
608                 my $method = $self->get_override_method_modifier($method_name);
609                 my ($package) = Class::MOP::get_code_info($method);
610                 # if it is a class, we just add it
611                 $other->add_override_method_modifier($method_name, $method, $package);
612             }
613         }
614     }
615 }
616
617 sub _apply_method_modifiers {
618     my ($self, $modifier_type, $other) = @_;
619     my $add = "add_${modifier_type}_method_modifier";
620     my $get = "get_${modifier_type}_method_modifiers";
621     foreach my $method_name ($self->get_method_modifier_list($modifier_type)) {
622         $other->$add(
623             $method_name,
624             $_
625         ) foreach $self->$get($method_name);
626     }
627 }
628
629 sub _apply_before_method_modifiers { (shift)->_apply_method_modifiers('before' => @_) }
630 sub _apply_around_method_modifiers { (shift)->_apply_method_modifiers('around' => @_) }
631 sub _apply_after_method_modifiers  { (shift)->_apply_method_modifiers('after'  => @_) }
632
633 #####################################################################
634 ## NOTE:
635 ## This is Moose::Meta::Role as defined by Moose (plus the use of 
636 ## MooseX::AttributeHelpers module). It is here as a reference to 
637 ## make it easier to see what is happening above with all the meta
638 ## programming. - SL
639 #####################################################################
640 #
641 # has 'roles' => (
642 #     metaclass => 'Collection::Array',
643 #     reader    => 'get_roles',
644 #     isa       => 'ArrayRef[Moose::Meta::Roles]',
645 #     default   => sub { [] },
646 #     provides  => {
647 #         'push' => 'add_role',
648 #     }
649 # );
650
651 # has 'excluded_roles_map' => (
652 #     metaclass => 'Collection::Hash',
653 #     reader    => 'get_excluded_roles_map',
654 #     isa       => 'HashRef[Str]',
655 #     provides  => {
656 #         # Not exactly set, cause it sets multiple
657 #         'set'    => 'add_excluded_roles',
658 #         'keys'   => 'get_excluded_roles_list',
659 #         'exists' => 'excludes_role',
660 #     }
661 # );
662
663 # has 'attribute_map' => (
664 #     metaclass => 'Collection::Hash',
665 #     reader    => 'get_attribute_map',
666 #     isa       => 'HashRef[Str]',    
667 #     provides => {
668 #         # 'set'  => 'add_attribute' # has some special crap in it
669 #         'get'    => 'get_attribute',
670 #         'keys'   => 'get_attribute_list',
671 #         'exists' => 'has_attribute',
672 #         # Not exactly delete, cause it sets multiple
673 #         'delete' => 'remove_attribute',    
674 #     }
675 # );
676
677 # has 'required_methods' => (
678 #     metaclass => 'Collection::Hash',
679 #     reader    => 'get_required_methods_map',
680 #     isa       => 'HashRef[Str]',
681 #     provides  => {    
682 #         # not exactly set, or delete since it works for multiple 
683 #         'set'    => 'add_required_methods',
684 #         'delete' => 'remove_required_methods',
685 #         'keys'   => 'get_required_method_list',
686 #         'exists' => 'requires_method',    
687 #     }
688 # );
689
690 # # the before, around and after modifiers are 
691 # # HASH keyed by method-name, with ARRAY of 
692 # # CODE refs to apply in that order
693
694 # has 'before_method_modifiers' => (
695 #     metaclass => 'Collection::Hash',    
696 #     reader    => 'get_before_method_modifiers_map',
697 #     isa       => 'HashRef[ArrayRef[CodeRef]]',
698 #     provides  => {
699 #         'keys'   => 'get_before_method_modifiers',
700 #         'exists' => 'has_before_method_modifiers',   
701 #         # This actually makes sure there is an 
702 #         # ARRAY at the given key, and pushed onto
703 #         # it. It also checks for duplicates as well
704 #         # 'add'  => 'add_before_method_modifier'     
705 #     }    
706 # );
707
708 # has 'after_method_modifiers' => (
709 #     metaclass => 'Collection::Hash',    
710 #     reader    =>'get_after_method_modifiers_map',
711 #     isa       => 'HashRef[ArrayRef[CodeRef]]',
712 #     provides  => {
713 #         'keys'   => 'get_after_method_modifiers',
714 #         'exists' => 'has_after_method_modifiers', 
715 #         # This actually makes sure there is an 
716 #         # ARRAY at the given key, and pushed onto
717 #         # it. It also checks for duplicates as well          
718 #         # 'add'  => 'add_after_method_modifier'     
719 #     }    
720 # );
721 #     
722 # has 'around_method_modifiers' => (
723 #     metaclass => 'Collection::Hash',    
724 #     reader    =>'get_around_method_modifiers_map',
725 #     isa       => 'HashRef[ArrayRef[CodeRef]]',
726 #     provides  => {
727 #         'keys'   => 'get_around_method_modifiers',
728 #         'exists' => 'has_around_method_modifiers',   
729 #         # This actually makes sure there is an 
730 #         # ARRAY at the given key, and pushed onto
731 #         # it. It also checks for duplicates as well        
732 #         # 'add'  => 'add_around_method_modifier'     
733 #     }    
734 # );
735
736 # # override is similar to the other modifiers
737 # # except that it is not an ARRAY of code refs
738 # # but instead just a single name->code mapping
739 #     
740 # has 'override_method_modifiers' => (
741 #     metaclass => 'Collection::Hash',    
742 #     reader    =>'get_override_method_modifiers_map',
743 #     isa       => 'HashRef[CodeRef]',   
744 #     provides  => {
745 #         'keys'   => 'get_override_method_modifier',
746 #         'exists' => 'has_override_method_modifier',   
747 #         'add'    => 'add_override_method_modifier', # checks for local method ..     
748 #     }
749 # );
750 #     
751 #####################################################################
752
753
754 1;
755
756 __END__
757
758 =pod
759
760 =head1 NAME
761
762 Moose::Meta::Role - The Moose Role metaclass
763
764 =head1 DESCRIPTION
765
766 Please see L<Moose::Role> for more information about roles.
767 For the most part, this has no user-serviceable parts inside
768 this module. It's API is still subject to some change (although
769 probably not that much really).
770
771 =head1 METHODS
772
773 =over 4
774
775 =item B<meta>
776
777 =item B<new>
778
779 =item B<apply>
780
781 =item B<combine>
782
783 =back
784
785 =over 4
786
787 =item B<name>
788
789 =item B<version>
790
791 =item B<role_meta>
792
793 =back
794
795 =over 4
796
797 =item B<get_roles>
798
799 =item B<add_role>
800
801 =item B<does_role>
802
803 =back
804
805 =over 4
806
807 =item B<add_excluded_roles>
808
809 =item B<excludes_role>
810
811 =item B<get_excluded_roles_list>
812
813 =item B<get_excluded_roles_map>
814
815 =item B<calculate_all_roles>
816
817 =back
818
819 =over 4
820
821 =item B<method_metaclass>
822
823 =item B<find_method_by_name>
824
825 =item B<get_method>
826
827 =item B<has_method>
828
829 =item B<alias_method>
830
831 =item B<get_method_list>
832
833 =item B<get_method_map>
834
835 =item B<update_package_cache_flag>
836
837 =item B<reset_package_cache_flag>
838
839 =back
840
841 =over 4
842
843 =item B<add_attribute>
844
845 =item B<has_attribute>
846
847 =item B<get_attribute>
848
849 =item B<get_attribute_list>
850
851 =item B<get_attribute_map>
852
853 =item B<remove_attribute>
854
855 =back
856
857 =over 4
858
859 =item B<add_required_methods>
860
861 =item B<remove_required_methods>
862
863 =item B<get_required_method_list>
864
865 =item B<get_required_methods_map>
866
867 =item B<requires_method>
868
869 =back
870
871 =over 4
872
873 =item B<add_after_method_modifier>
874
875 =item B<add_around_method_modifier>
876
877 =item B<add_before_method_modifier>
878
879 =item B<add_override_method_modifier>
880
881 =over 4
882
883 =back
884
885 =item B<has_after_method_modifiers>
886
887 =item B<has_around_method_modifiers>
888
889 =item B<has_before_method_modifiers>
890
891 =item B<has_override_method_modifier>
892
893 =over 4
894
895 =back
896
897 =item B<get_after_method_modifiers>
898
899 =item B<get_around_method_modifiers>
900
901 =item B<get_before_method_modifiers>
902
903 =item B<get_method_modifier_list>
904
905 =over 4
906
907 =back
908
909 =item B<get_override_method_modifier>
910
911 =item B<get_after_method_modifiers_map>
912
913 =item B<get_around_method_modifiers_map>
914
915 =item B<get_before_method_modifiers_map>
916
917 =item B<get_override_method_modifiers_map>
918
919 =back
920
921 =head1 BUGS
922
923 All complex software has bugs lurking in it, and this module is no
924 exception. If you find a bug please either email me, or add the bug
925 to cpan-RT.
926
927 =head1 AUTHOR
928
929 Stevan Little E<lt>stevan@iinteractive.comE<gt>
930
931 =head1 COPYRIGHT AND LICENSE
932
933 Copyright 2006, 2007 by Infinity Interactive, Inc.
934
935 L<http://www.iinteractive.com>
936
937 This library is free software; you can redistribute it and/or modify
938 it under the same terms as Perl itself.
939
940 =cut