Depend directly on Data::OptList
[gitmo/Moose.git] / lib / Moose / Meta / Role.pm
CommitLineData
e185c027 1
2package Moose::Meta::Role;
3
4use strict;
5use warnings;
6use metaclass;
7
21f1e231 8use Scalar::Util 'blessed';
b6a00b82 9use Carp 'confess';
bdabd620 10
4b2189ce 11our $VERSION = '0.72';
e606ae5f 12$VERSION = eval $VERSION;
d44714be 13our $AUTHORITY = 'cpan:STEVAN';
e185c027 14
8ee73eeb 15use Moose::Meta::Class;
39b3bc94 16use Moose::Meta::Role::Method;
d67145ed 17use Moose::Meta::Role::Method::Required;
8ee73eeb 18
68efb014 19use base 'Class::MOP::Module';
80572233 20
fb1e11d5 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## ------------------------------------------------------------------
80572233 32
21716c07 33my $META = __PACKAGE__->meta;
34
35## ------------------------------------------------------------------
36## attributes ...
e185c027 37
21716c07 38# NOTE:
39# since roles are lazy, we hold all the attributes
fb1e11d5 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
21716c07 43# using a little of that meta-programmin' magic
fb1e11d5 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
21716c07 48# very compact solution to this normally verbose
49# problem.
50# - SL
51
52foreach my $action (
fb1e11d5 53 {
54 name => 'excluded_roles_map',
55 attr_reader => 'get_excluded_roles_map' ,
21716c07 56 methods => {
fb1e11d5 57 add => 'add_excluded_roles',
58 get_list => 'get_excluded_roles_list',
59 existence => 'excludes_role',
21716c07 60 }
61 },
fb1e11d5 62 {
63 name => 'required_methods',
21716c07 64 attr_reader => 'get_required_methods_map',
65 methods => {
fb1e11d5 66 add => 'add_required_methods',
21716c07 67 remove => 'remove_required_methods',
68 get_list => 'get_required_method_list',
69 existence => 'requires_method',
70 }
709c321c 71 },
21716c07 72 {
fb1e11d5 73 name => 'attribute_map',
21716c07 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) {
fb1e11d5 83
21716c07 84 my $attr_reader = $action->{attr_reader};
85 my $methods = $action->{methods};
fb1e11d5 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
21716c07 94 $META->add_method($methods->{add} => sub {
95 my ($self, @values) = @_;
fb1e11d5 96 $self->$attr_reader->{$_} = undef foreach @values;
21716c07 97 }) if exists $methods->{add};
fb1e11d5 98
21716c07 99 $META->add_method($methods->{get_list} => sub {
100 my ($self) = @_;
fb1e11d5 101 keys %{$self->$attr_reader};
102 }) if exists $methods->{get_list};
103
21716c07 104 $META->add_method($methods->{get} => sub {
105 my ($self, $name) = @_;
fb1e11d5 106 $self->$attr_reader->{$name}
107 }) if exists $methods->{get};
108
21716c07 109 $META->add_method($methods->{existence} => sub {
110 my ($self, $name) = @_;
fb1e11d5 111 exists $self->$attr_reader->{$name} ? 1 : 0;
112 }) if exists $methods->{existence};
113
21716c07 114 $META->add_method($methods->{remove} => sub {
115 my ($self, @values) = @_;
116 delete $self->$attr_reader->{$_} foreach @values;
fb1e11d5 117 }) if exists $methods->{remove};
21716c07 118}
d79e62fd 119
21716c07 120## some things don't always fit, so they go here ...
80572233 121
21716c07 122sub add_attribute {
123 my $self = shift;
124 my $name = shift;
70ea9161 125 unless ( defined $name && $name ) {
126 require Moose;
127 Moose->throw_error("You must provide a name for the attribute");
128 }
21716c07 129 my $attr_desc;
130 if (scalar @_ == 1 && ref($_[0]) eq 'HASH') {
131 $attr_desc = $_[0];
132 }
133 else {
134 $attr_desc = { @_ };
135 }
136 $self->get_attribute_map->{$name} = $attr_desc;
137}
e185c027 138
bca01282 139# DEPRECATED
140# sub _clean_up_required_methods {
141# my $self = shift;
142# foreach my $method ($self->get_required_method_list) {
143# $self->remove_required_methods($method)
144# if $self->has_method($method);
145# }
146# }
1331430a 147
21716c07 148## ------------------------------------------------------------------
149## method modifiers
150
21716c07 151# NOTE:
fb1e11d5 152# the before/around/after method modifiers are
21716c07 153# stored by name, but there can be many methods
154# then associated with that name. So again we have
155# lots of similar functionality, so we can do some
156# meta-programmin' and save some time.
157# - SL
158
159foreach my $modifier_type (qw[ before around after ]) {
fb1e11d5 160
161 my $attr_reader = "get_${modifier_type}_method_modifiers_map";
21716c07 162
fb1e11d5 163 # create the attribute ...
164 $META->add_attribute("${modifier_type}_method_modifiers" => (
165 reader => $attr_reader,
166 default => sub { {} }
167 ));
168
169 # and some helper methods ...
21716c07 170 $META->add_method("get_${modifier_type}_method_modifiers" => sub {
171 my ($self, $method_name) = @_;
fb1e11d5 172 #return () unless exists $self->$attr_reader->{$method_name};
21716c07 173 @{$self->$attr_reader->{$method_name}};
174 });
fb1e11d5 175
21716c07 176 $META->add_method("has_${modifier_type}_method_modifiers" => sub {
177 my ($self, $method_name) = @_;
178 # NOTE:
fb1e11d5 179 # for now we assume that if it exists,..
21716c07 180 # it has at least one modifier in it
181 (exists $self->$attr_reader->{$method_name}) ? 1 : 0;
fb1e11d5 182 });
183
21716c07 184 $META->add_method("add_${modifier_type}_method_modifier" => sub {
185 my ($self, $method_name, $method) = @_;
fb1e11d5 186
187 $self->$attr_reader->{$method_name} = []
21716c07 188 unless exists $self->$attr_reader->{$method_name};
fb1e11d5 189
21716c07 190 my $modifiers = $self->$attr_reader->{$method_name};
fb1e11d5 191
21716c07 192 # NOTE:
fb1e11d5 193 # check to see that we aren't adding the
194 # same code twice. We err in favor of the
21716c07 195 # first on here, this may not be as expected
196 foreach my $modifier (@{$modifiers}) {
197 return if $modifier == $method;
198 }
fb1e11d5 199
21716c07 200 push @{$modifiers} => $method;
201 });
fb1e11d5 202
21716c07 203}
1331430a 204
21716c07 205## ------------------------------------------------------------------
206## override method mofidiers
0558683c 207
fb1e11d5 208$META->add_attribute('override_method_modifiers' => (
209 reader => 'get_override_method_modifiers_map',
210 default => sub { {} }
211));
212
21716c07 213# NOTE:
fb1e11d5 214# these are a little different because there
21716c07 215# can only be one per name, whereas the other
216# method modifiers can have multiples.
217# - SL
0558683c 218
21716c07 219sub add_override_method_modifier {
220 my ($self, $method_name, $method) = @_;
221 (!$self->has_method($method_name))
c245d69b 222 || Moose->throw_error("Cannot add an override of method '$method_name' " .
4c0b3599 223 "because there is a local version of '$method_name'");
fb1e11d5 224 $self->get_override_method_modifiers_map->{$method_name} = $method;
21716c07 225}
0558683c 226
21716c07 227sub has_override_method_modifier {
228 my ($self, $method_name) = @_;
229 # NOTE:
fb1e11d5 230 # for now we assume that if it exists,..
21716c07 231 # it has at least one modifier in it
fb1e11d5 232 (exists $self->get_override_method_modifiers_map->{$method_name}) ? 1 : 0;
21716c07 233}
0558683c 234
21716c07 235sub get_override_method_modifier {
236 my ($self, $method_name) = @_;
fb1e11d5 237 $self->get_override_method_modifiers_map->{$method_name};
21716c07 238}
0558683c 239
21716c07 240## general list accessor ...
80572233 241
21716c07 242sub get_method_modifier_list {
243 my ($self, $modifier_type) = @_;
fb1e11d5 244 my $accessor = "get_${modifier_type}_method_modifiers_map";
21716c07 245 keys %{$self->$accessor};
246}
e185c027 247
e606ae5f 248sub reset_package_cache_flag { (shift)->{'_package_cache_flag'} = undef }
249sub update_package_cache_flag {
250 my $self = shift;
251 $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name);
252}
253
254
255
21716c07 256## ------------------------------------------------------------------
80572233 257## subroles
258
21716c07 259__PACKAGE__->meta->add_attribute('roles' => (
260 reader => 'get_roles',
261 default => sub { [] }
262));
263
80572233 264sub add_role {
265 my ($self, $role) = @_;
266 (blessed($role) && $role->isa('Moose::Meta::Role'))
c245d69b 267 || Moose->throw_error("Roles must be instances of Moose::Meta::Role");
80572233 268 push @{$self->get_roles} => $role;
e606ae5f 269 $self->reset_package_cache_flag;
80572233 270}
271
b8aeb4dc 272sub calculate_all_roles {
273 my $self = shift;
274 my %seen;
fb1e11d5 275 grep {
276 !$seen{$_->name}++
277 } ($self, map {
278 $_->calculate_all_roles
279 } @{ $self->get_roles });
b8aeb4dc 280}
281
80572233 282sub does_role {
283 my ($self, $role_name) = @_;
284 (defined $role_name)
c245d69b 285 || Moose->throw_error("You must supply a role name to look for");
bdabd620 286 # if we are it,.. then return true
287 return 1 if $role_name eq $self->name;
288 # otherwise.. check our children
80572233 289 foreach my $role (@{$self->get_roles}) {
bdabd620 290 return 1 if $role->does_role($role_name);
80572233 291 }
292 return 0;
293}
294
21716c07 295## ------------------------------------------------------------------
fb1e11d5 296## methods
1331430a 297
21716c07 298sub method_metaclass { 'Moose::Meta::Role::Method' }
80572233 299
fb1e11d5 300sub get_method_map {
093b12c2 301 my $self = shift;
e606ae5f 302
303 my $current = Class::MOP::check_package_cache_flag($self->name);
304
305 if (defined $self->{'_package_cache_flag'} && $self->{'_package_cache_flag'} == $current) {
306 return $self->{'methods'} ||= {};
307 }
308
309 $self->{_package_cache_flag} = $current;
310
311 my $map = $self->{'methods'} ||= {};
fb1e11d5 312
313 my $role_name = $self->name;
314 my $method_metaclass = $self->method_metaclass;
315
534000fd 316 my $all_code = $self->get_all_package_symbols('CODE');
fb1e11d5 317
534000fd 318 foreach my $symbol (keys %{ $all_code }) {
319 my $code = $all_code->{$symbol};
fb1e11d5 320
e606ae5f 321 next if exists $map->{$symbol} &&
322 defined $map->{$symbol} &&
323 $map->{$symbol}->body == $code;
324
fb1e11d5 325 my ($pkg, $name) = Class::MOP::get_code_info($code);
326
327 if ($pkg->can('meta')
328 # NOTE:
329 # we don't know what ->meta we are calling
330 # here, so we need to be careful cause it
331 # just might blow up at us, or just complain
332 # loudly (in the case of Curses.pm) so we
333 # just be a little overly cautious here.
334 # - SL
e606ae5f 335 && eval { no warnings; blessed($pkg->meta) } # FIXME calls meta
fb1e11d5 336 && $pkg->meta->isa('Moose::Meta::Role')) {
337 my $role = $pkg->meta->name;
338 next unless $self->does_role($role);
339 }
340 else {
2887c827 341 # NOTE:
342 # in 5.10 constant.pm the constants show up
343 # as being in the right package, but in pre-5.10
344 # they show up as constant::__ANON__ so we
345 # make an exception here to be sure that things
346 # work as expected in both.
347 # - SL
348 unless ($pkg eq 'constant' && $name eq '__ANON__') {
349 next if ($pkg || '') ne $role_name ||
350 (($name || '') ne '__ANON__' && ($pkg || '') ne $role_name);
351 }
fb1e11d5 352 }
c4538447 353
1b2aea39 354 $map->{$symbol} = $method_metaclass->wrap(
355 $code,
356 package_name => $role_name,
357 name => $name
358 );
fb1e11d5 359 }
360
361 return $map;
093b12c2 362}
363
fb1e11d5 364sub get_method {
365 my ($self, $name) = @_;
c4538447 366 $self->get_method_map->{$name};
fb1e11d5 367}
40e89659 368
fb1e11d5 369sub has_method {
370 my ($self, $name) = @_;
371 exists $self->get_method_map->{$name} ? 1 : 0
e185c027 372}
373
8c5f7ce4 374# FIXME this is copy-pasted from Class::MOP::Class
e606ae5f 375# refactor to inherit from some common base
376sub wrap_method_body {
377 my ( $self, %args ) = @_;
378
87e63626 379 ('CODE' eq ref $args{body})
c245d69b 380 || Moose->throw_error("Your code block must be a CODE reference");
e606ae5f 381
87e63626 382 $self->method_metaclass->wrap(
e606ae5f 383 package_name => $self->name,
384 %args,
87e63626 385 );
e606ae5f 386}
387
388sub add_method {
389 my ($self, $method_name, $method) = @_;
390 (defined $method_name && $method_name)
c245d69b 391 || Moose->throw_error("You must define a method name");
e606ae5f 392
393 my $body;
394 if (blessed($method)) {
395 $body = $method->body;
87e63626 396 if ($method->package_name ne $self->name) {
e606ae5f 397 $method = $method->clone(
398 package_name => $self->name,
87e63626 399 name => $method_name
e606ae5f 400 ) if $method->can('clone');
401 }
402 }
403 else {
404 $body = $method;
405 $method = $self->wrap_method_body( body => $body, name => $method_name );
406 }
407
408 $method->attach_to_class($self);
409
410 $self->get_method_map->{$method_name} = $method;
411
412 my $full_method_name = ($self->name . '::' . $method_name);
413 $self->add_package_symbol(
414 { sigil => '&', type => 'CODE', name => $method_name },
415 Class::MOP::subname($full_method_name => $body)
416 );
417
418 $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
419}
420
1db8ecc7 421sub find_method_by_name { (shift)->get_method(@_) }
093b12c2 422
fb1e11d5 423sub get_method_list {
424 my $self = shift;
425 grep { !/^meta$/ } keys %{$self->get_method_map};
426}
427
428sub alias_method {
87e63626 429 my $self = shift;
fb1e11d5 430
87e63626 431 $self->add_method(@_);
fb1e11d5 432}
433
21716c07 434## ------------------------------------------------------------------
fb1e11d5 435## role construction
21716c07 436## ------------------------------------------------------------------
e185c027 437
21716c07 438sub apply {
bca01282 439 my ($self, $other, @args) = @_;
440
441 (blessed($other))
c245d69b 442 || Moose->throw_error("You must pass in an blessed instance");
bca01282 443
1c9db35c 444 if ($other->isa('Moose::Meta::Role')) {
445 require Moose::Meta::Role::Application::ToRole;
709c321c 446 return Moose::Meta::Role::Application::ToRole->new(@args)->apply($self, $other);
1c9db35c 447 }
448 elsif ($other->isa('Moose::Meta::Class')) {
449 require Moose::Meta::Role::Application::ToClass;
709c321c 450 return Moose::Meta::Role::Application::ToClass->new(@args)->apply($self, $other);
1c9db35c 451 }
452 else {
453 require Moose::Meta::Role::Application::ToInstance;
709c321c 454 return Moose::Meta::Role::Application::ToInstance->new(@args)->apply($self, $other);
1c9db35c 455 }
0558683c 456}
457
21716c07 458sub combine {
a4e516f6 459 my ($class, @role_specs) = @_;
21716c07 460
fb1e11d5 461 require Moose::Meta::Role::Application::RoleSummation;
a4e516f6 462 require Moose::Meta::Role::Composite;
463
28412c0b 464 my (@roles, %role_params);
465 while (@role_specs) {
466 my ($role, $params) = @{ splice @role_specs, 0, 1 };
467 push @roles => $role->meta;
468 next unless defined $params;
469 $role_params{$role} = $params;
470 }
21716c07 471
fb1e11d5 472 my $c = Moose::Meta::Role::Composite->new(roles => \@roles);
a4e516f6 473 Moose::Meta::Role::Application::RoleSummation->new(
28412c0b 474 role_params => \%role_params
a4e516f6 475 )->apply($c);
28412c0b 476
fb1e11d5 477 return $c;
0558683c 478}
479
b6a00b82 480sub create {
2d5f3fab 481 my ( $role, $package_name, %options ) = @_;
b6a00b82 482
2d5f3fab 483 $options{package} = $package_name;
b6a00b82 484
485 (ref $options{attributes} eq 'HASH')
486 || confess "You must pass a HASH ref of attributes"
487 if exists $options{attributes};
488
489 (ref $options{methods} eq 'HASH')
490 || confess "You must pass a HASH ref of methods"
491 if exists $options{methods};
492
493 $role->SUPER::create(%options);
494
2d5f3fab 495 my (%initialize_options) = %options;
b6a00b82 496 delete @initialize_options{qw(
497 package
498 attributes
499 methods
500 version
501 authority
502 )};
503
504 my $meta = $role->initialize( $package_name => %initialize_options );
505
506 # FIXME totally lame
507 $meta->add_method('meta' => sub {
508 $role->initialize(ref($_[0]) || $_[0]);
509 });
510
511 if (exists $options{attributes}) {
512 foreach my $attribute_name (keys %{$options{attributes}}) {
513 my $attr = $options{attributes}->{$attribute_name};
514 $meta->add_attribute($attribute_name => $attr);
515 }
516 }
517
518 if (exists $options{methods}) {
519 foreach my $method_name (keys %{$options{methods}}) {
520 $meta->add_method($method_name, $options{methods}->{$method_name});
521 }
522 }
523
d1765290 524 Class::MOP::weaken_metaclass($meta->name)
525 if $meta->is_anon_role;
526
b6a00b82 527 return $meta;
528}
529
c9ee520d 530# anonymous roles. most of it is copied straight out of Class::MOP::Class.
531# an intrepid hacker might find great riches if he unifies this code with that
532# code in Class::MOP::Module or Class::MOP::Package
533{
534 # NOTE:
535 # this should be sufficient, if you have a
536 # use case where it is not, write a test and
537 # I will change it.
538 my $ANON_ROLE_SERIAL = 0;
539
540 # NOTE:
541 # we need a sufficiently annoying prefix
542 # this should suffice for now, this is
543 # used in a couple of places below, so
544 # need to put it up here for now.
545 my $ANON_ROLE_PREFIX = 'Moose::Meta::Role::__ANON__::SERIAL::';
546
547 sub is_anon_role {
548 my $self = shift;
549 no warnings 'uninitialized';
550 $self->name =~ /^$ANON_ROLE_PREFIX/;
551 }
552
553 sub create_anon_role {
554 my ($role, %options) = @_;
555 my $package_name = $ANON_ROLE_PREFIX . ++$ANON_ROLE_SERIAL;
556 return $role->create($package_name, %options);
557 }
558
559 # NOTE:
560 # this will only get called for
561 # anon-roles, all other calls
562 # are assumed to occur during
563 # global destruction and so don't
564 # really need to be handled explicitly
565 sub DESTROY {
566 my $self = shift;
567
568 return if Class::MOP::in_global_destruction(); # it'll happen soon anyway and this just makes things more complicated
569
570 no warnings 'uninitialized';
571 return unless $self->name =~ /^$ANON_ROLE_PREFIX/;
572
573 # XXX: is this necessary for us? I don't understand what it's doing
574 # -sartak
575
576 # Moose does a weird thing where it replaces the metaclass for
577 # class when fixing metaclass incompatibility. In that case,
578 # we don't want to clean out the namespace now. We can detect
579 # that because Moose will explicitly update the singleton
580 # cache in Class::MOP.
581 #my $current_meta = Class::MOP::get_metaclass_by_name($self->name);
582 #return if $current_meta ne $self;
583
584 my ($serial_id) = ($self->name =~ /^$ANON_ROLE_PREFIX(\d+)/);
585 no strict 'refs';
586 foreach my $key (keys %{$ANON_ROLE_PREFIX . $serial_id}) {
587 delete ${$ANON_ROLE_PREFIX . $serial_id}{$key};
588 }
589 delete ${'main::' . $ANON_ROLE_PREFIX}{$serial_id . '::'};
590 }
591}
592
fb1e11d5 593#####################################################################
594## NOTE:
595## This is Moose::Meta::Role as defined by Moose (plus the use of
596## MooseX::AttributeHelpers module). It is here as a reference to
597## make it easier to see what is happening above with all the meta
598## programming. - SL
599#####################################################################
600#
601# has 'roles' => (
602# metaclass => 'Collection::Array',
603# reader => 'get_roles',
604# isa => 'ArrayRef[Moose::Meta::Roles]',
605# default => sub { [] },
606# provides => {
607# 'push' => 'add_role',
608# }
609# );
610#
611# has 'excluded_roles_map' => (
612# metaclass => 'Collection::Hash',
613# reader => 'get_excluded_roles_map',
614# isa => 'HashRef[Str]',
615# provides => {
616# # Not exactly set, cause it sets multiple
617# 'set' => 'add_excluded_roles',
618# 'keys' => 'get_excluded_roles_list',
619# 'exists' => 'excludes_role',
620# }
621# );
622#
623# has 'attribute_map' => (
624# metaclass => 'Collection::Hash',
625# reader => 'get_attribute_map',
626# isa => 'HashRef[Str]',
627# provides => {
628# # 'set' => 'add_attribute' # has some special crap in it
629# 'get' => 'get_attribute',
630# 'keys' => 'get_attribute_list',
631# 'exists' => 'has_attribute',
632# # Not exactly delete, cause it sets multiple
633# 'delete' => 'remove_attribute',
634# }
635# );
636#
637# has 'required_methods' => (
638# metaclass => 'Collection::Hash',
639# reader => 'get_required_methods_map',
640# isa => 'HashRef[Str]',
641# provides => {
642# # not exactly set, or delete since it works for multiple
643# 'set' => 'add_required_methods',
644# 'delete' => 'remove_required_methods',
645# 'keys' => 'get_required_method_list',
646# 'exists' => 'requires_method',
647# }
648# );
649#
650# # the before, around and after modifiers are
651# # HASH keyed by method-name, with ARRAY of
652# # CODE refs to apply in that order
653#
654# has 'before_method_modifiers' => (
655# metaclass => 'Collection::Hash',
656# reader => 'get_before_method_modifiers_map',
657# isa => 'HashRef[ArrayRef[CodeRef]]',
658# provides => {
659# 'keys' => 'get_before_method_modifiers',
660# 'exists' => 'has_before_method_modifiers',
661# # This actually makes sure there is an
662# # ARRAY at the given key, and pushed onto
663# # it. It also checks for duplicates as well
664# # 'add' => 'add_before_method_modifier'
665# }
666# );
667#
668# has 'after_method_modifiers' => (
669# metaclass => 'Collection::Hash',
670# reader =>'get_after_method_modifiers_map',
671# isa => 'HashRef[ArrayRef[CodeRef]]',
672# provides => {
673# 'keys' => 'get_after_method_modifiers',
674# 'exists' => 'has_after_method_modifiers',
675# # This actually makes sure there is an
676# # ARRAY at the given key, and pushed onto
677# # it. It also checks for duplicates as well
678# # 'add' => 'add_after_method_modifier'
679# }
680# );
681#
682# has 'around_method_modifiers' => (
683# metaclass => 'Collection::Hash',
684# reader =>'get_around_method_modifiers_map',
685# isa => 'HashRef[ArrayRef[CodeRef]]',
686# provides => {
687# 'keys' => 'get_around_method_modifiers',
688# 'exists' => 'has_around_method_modifiers',
689# # This actually makes sure there is an
690# # ARRAY at the given key, and pushed onto
691# # it. It also checks for duplicates as well
692# # 'add' => 'add_around_method_modifier'
693# }
694# );
695#
696# # override is similar to the other modifiers
697# # except that it is not an ARRAY of code refs
698# # but instead just a single name->code mapping
699#
700# has 'override_method_modifiers' => (
701# metaclass => 'Collection::Hash',
702# reader =>'get_override_method_modifiers_map',
703# isa => 'HashRef[CodeRef]',
704# provides => {
705# 'keys' => 'get_override_method_modifier',
706# 'exists' => 'has_override_method_modifier',
707# 'add' => 'add_override_method_modifier', # checks for local method ..
708# }
709# );
710#
711#####################################################################
712
713
e185c027 7141;
715
716__END__
717
718=pod
719
720=head1 NAME
721
722Moose::Meta::Role - The Moose Role metaclass
723
724=head1 DESCRIPTION
725
fb1e11d5 726Please see L<Moose::Role> for more information about roles.
d44714be 727For the most part, this has no user-serviceable parts inside
fb1e11d5 728this module. It's API is still subject to some change (although
02a0fb52 729probably not that much really).
79592a54 730
e185c027 731=head1 METHODS
732
733=over 4
734
735=item B<meta>
736
737=item B<new>
738
78cd1d3b 739=item B<apply>
740
e606ae5f 741=item B<apply_to_metaclass_instance>
742
db1ab48d 743=item B<combine>
744
e185c027 745=back
746
747=over 4
748
749=item B<name>
750
751=item B<version>
752
753=item B<role_meta>
754
755=back
756
757=over 4
758
80572233 759=item B<get_roles>
760
761=item B<add_role>
762
763=item B<does_role>
764
765=back
766
767=over 4
768
d79e62fd 769=item B<add_excluded_roles>
770
771=item B<excludes_role>
772
773=item B<get_excluded_roles_list>
774
775=item B<get_excluded_roles_map>
776
2b14ac61 777=item B<calculate_all_roles>
778
d79e62fd 779=back
780
781=over 4
782
68efb014 783=item B<method_metaclass>
784
be4427d0 785=item B<find_method_by_name>
786
e185c027 787=item B<get_method>
788
789=item B<has_method>
790
e606ae5f 791=item B<add_method>
792
793=item B<wrap_method_body>
794
bdabd620 795=item B<alias_method>
796
e185c027 797=item B<get_method_list>
798
093b12c2 799=item B<get_method_map>
800
638853cb 801=item B<update_package_cache_flag>
802
53dd42d8 803=item B<reset_package_cache_flag>
804
e185c027 805=back
806
807=over 4
808
809=item B<add_attribute>
810
811=item B<has_attribute>
812
813=item B<get_attribute>
814
815=item B<get_attribute_list>
816
817=item B<get_attribute_map>
818
819=item B<remove_attribute>
820
821=back
822
823=over 4
824
1331430a 825=item B<add_required_methods>
826
38f1204c 827=item B<remove_required_methods>
828
1331430a 829=item B<get_required_method_list>
830
831=item B<get_required_methods_map>
832
833=item B<requires_method>
834
835=back
836
0558683c 837=over 4
838
839=item B<add_after_method_modifier>
840
841=item B<add_around_method_modifier>
842
843=item B<add_before_method_modifier>
844
845=item B<add_override_method_modifier>
846
847=over 4
848
849=back
850
851=item B<has_after_method_modifiers>
852
853=item B<has_around_method_modifiers>
854
855=item B<has_before_method_modifiers>
856
857=item B<has_override_method_modifier>
858
859=over 4
860
861=back
862
863=item B<get_after_method_modifiers>
864
865=item B<get_around_method_modifiers>
866
867=item B<get_before_method_modifiers>
868
869=item B<get_method_modifier_list>
870
871=over 4
872
873=back
874
875=item B<get_override_method_modifier>
876
877=item B<get_after_method_modifiers_map>
878
879=item B<get_around_method_modifiers_map>
880
881=item B<get_before_method_modifiers_map>
882
883=item B<get_override_method_modifiers_map>
884
885=back
886
505065c4 887=over 4
888
889=item B<create>
890
891=item B<create_anon_role>
892
893=item B<is_anon_role>
894
895=back
896
e185c027 897=head1 BUGS
898
fb1e11d5 899All complex software has bugs lurking in it, and this module is no
e185c027 900exception. If you find a bug please either email me, or add the bug
901to cpan-RT.
902
903=head1 AUTHOR
904
905Stevan Little E<lt>stevan@iinteractive.comE<gt>
906
907=head1 COPYRIGHT AND LICENSE
908
2840a3b2 909Copyright 2006-2009 by Infinity Interactive, Inc.
e185c027 910
911L<http://www.iinteractive.com>
912
913This library is free software; you can redistribute it and/or modify
fb1e11d5 914it under the same terms as Perl itself.
e185c027 915
b8aeb4dc 916=cut