| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Moose::Meta::Class; | 
| 2 |  |  |  |  |  |  | our $VERSION = '2.2203'; | 
| 3 |  |  |  |  |  |  |  | 
| 4 | 391 |  |  | 391 |  | 550566 | use strict; | 
|  | 391 |  |  |  |  | 806 |  | 
|  | 391 |  |  |  |  | 10723 |  | 
| 5 | 391 |  |  | 391 |  | 1782 | use warnings; | 
|  | 391 |  |  |  |  | 768 |  | 
|  | 391 |  |  |  |  | 8957 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 391 |  |  | 391 |  | 4665 | use Class::MOP; | 
|  | 391 |  |  |  |  | 779 |  | 
|  | 391 |  |  |  |  | 8482 |  | 
| 8 | 391 |  |  | 391 |  | 1942 | use Data::OptList; | 
|  | 391 |  |  |  |  | 858 |  | 
|  | 391 |  |  |  |  | 3048 |  | 
| 9 | 391 |  |  | 391 |  | 15368 | use List::Util 1.33 qw( any ); | 
|  | 391 |  |  |  |  | 6922 |  | 
|  | 391 |  |  |  |  | 23981 |  | 
| 10 | 391 |  |  | 391 |  | 2714 | use Scalar::Util 'blessed'; | 
|  | 391 |  |  |  |  | 897 |  | 
|  | 391 |  |  |  |  | 16816 |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 | 391 |  |  | 391 |  | 161337 | use Moose::Meta::Method::Overridden; | 
|  | 391 |  |  |  |  | 925 |  | 
|  | 391 |  |  |  |  | 12076 |  | 
| 13 | 391 |  |  | 391 |  | 159241 | use Moose::Meta::Method::Augmented; | 
|  | 391 |  |  |  |  | 933 |  | 
|  | 391 |  |  |  |  | 12762 |  | 
| 14 | 391 |  |  | 391 |  | 156613 | use Moose::Meta::Class::Immutable::Trait; | 
|  | 391 |  |  |  |  | 898 |  | 
|  | 391 |  |  |  |  | 11158 |  | 
| 15 | 391 |  |  | 391 |  | 151843 | use Moose::Meta::Method::Constructor; | 
|  | 391 |  |  |  |  | 926 |  | 
|  | 391 |  |  |  |  | 14024 |  | 
| 16 | 391 |  |  | 391 |  | 156856 | use Moose::Meta::Method::Destructor; | 
|  | 391 |  |  |  |  | 915 |  | 
|  | 391 |  |  |  |  | 13210 |  | 
| 17 | 391 |  |  | 391 |  | 149589 | use Moose::Meta::Method::Meta; | 
|  | 391 |  |  |  |  | 924 |  | 
|  | 391 |  |  |  |  | 12725 |  | 
| 18 | 391 |  |  | 391 |  | 2361 | use Moose::Util 'throw_exception'; | 
|  | 391 |  |  |  |  | 760 |  | 
|  | 391 |  |  |  |  | 1989 |  | 
| 19 | 391 |  |  | 391 |  | 81568 | use Class::MOP::MiniTrait; | 
|  | 391 |  |  |  |  | 794 |  | 
|  | 391 |  |  |  |  | 9160 |  | 
| 20 |  |  |  |  |  |  |  | 
| 21 | 391 |  |  | 391 |  | 1872 | use parent 'Class::MOP::Class'; | 
|  | 391 |  |  |  |  | 712 |  | 
|  | 391 |  |  |  |  | 1537 |  | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait'); | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | __PACKAGE__->meta->add_attribute('roles' => ( | 
| 26 |  |  |  |  |  |  | reader  => 'roles', | 
| 27 |  |  |  |  |  |  | default => sub { [] }, | 
| 28 |  |  |  |  |  |  | Class::MOP::_definition_context(), | 
| 29 |  |  |  |  |  |  | )); | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | __PACKAGE__->meta->add_attribute('role_applications' => ( | 
| 32 |  |  |  |  |  |  | reader  => '_get_role_applications', | 
| 33 |  |  |  |  |  |  | default => sub { [] }, | 
| 34 |  |  |  |  |  |  | Class::MOP::_definition_context(), | 
| 35 |  |  |  |  |  |  | )); | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | __PACKAGE__->meta->add_attribute( | 
| 38 |  |  |  |  |  |  | Class::MOP::Attribute->new('immutable_trait' => ( | 
| 39 |  |  |  |  |  |  | accessor => "immutable_trait", | 
| 40 |  |  |  |  |  |  | default  => 'Moose::Meta::Class::Immutable::Trait', | 
| 41 |  |  |  |  |  |  | Class::MOP::_definition_context(), | 
| 42 |  |  |  |  |  |  | )) | 
| 43 |  |  |  |  |  |  | ); | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | __PACKAGE__->meta->add_attribute('constructor_class' => ( | 
| 46 |  |  |  |  |  |  | accessor => 'constructor_class', | 
| 47 |  |  |  |  |  |  | default  => 'Moose::Meta::Method::Constructor', | 
| 48 |  |  |  |  |  |  | Class::MOP::_definition_context(), | 
| 49 |  |  |  |  |  |  | )); | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | __PACKAGE__->meta->add_attribute('destructor_class' => ( | 
| 52 |  |  |  |  |  |  | accessor => 'destructor_class', | 
| 53 |  |  |  |  |  |  | default  => 'Moose::Meta::Method::Destructor', | 
| 54 |  |  |  |  |  |  | Class::MOP::_definition_context(), | 
| 55 |  |  |  |  |  |  | )); | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | sub initialize { | 
| 58 | 2775 |  |  | 2775 | 1 | 8066 | my $class = shift; | 
| 59 | 2775 |  |  |  |  | 6890 | my @args = @_; | 
| 60 | 2775 | 50 |  |  |  | 10405 | unshift @args, 'package' if @args % 2; | 
| 61 | 2775 |  |  |  |  | 7804 | my %opts = @args; | 
| 62 | 2775 |  |  |  |  | 5930 | my $package = delete $opts{package}; | 
| 63 | 2775 |  | 100 |  |  | 7246 | return Class::MOP::get_metaclass_by_name($package) | 
| 64 |  |  |  |  |  |  | || $class->SUPER::initialize($package, | 
| 65 |  |  |  |  |  |  | 'attribute_metaclass' => 'Moose::Meta::Attribute', | 
| 66 |  |  |  |  |  |  | 'method_metaclass'    => 'Moose::Meta::Method', | 
| 67 |  |  |  |  |  |  | 'instance_metaclass'  => 'Moose::Meta::Instance', | 
| 68 |  |  |  |  |  |  | %opts, | 
| 69 |  |  |  |  |  |  | ); | 
| 70 |  |  |  |  |  |  | } | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | sub create { | 
| 73 | 701 |  |  | 701 | 1 | 92069 | my $class = shift; | 
| 74 | 701 |  |  |  |  | 2032 | my @args = @_; | 
| 75 |  |  |  |  |  |  |  | 
| 76 | 701 | 100 |  |  |  | 3073 | unshift @args, 'package' if @args % 2 == 1; | 
| 77 | 701 |  |  |  |  | 2580 | my %options = @args; | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | (ref $options{roles} eq 'ARRAY') | 
| 80 |  |  |  |  |  |  | || throw_exception( RolesInCreateTakesAnArrayRef => params => \%options ) | 
| 81 | 701 | 100 | 66 |  |  | 3340 | if exists $options{roles}; | 
| 82 |  |  |  |  |  |  |  | 
| 83 | 699 |  |  |  |  | 1578 | my $package = delete $options{package}; | 
| 84 | 699 |  |  |  |  | 1376 | my $roles   = delete $options{roles}; | 
| 85 |  |  |  |  |  |  |  | 
| 86 | 699 |  |  |  |  | 3601 | my $new_meta = $class->SUPER::create($package, %options); | 
| 87 |  |  |  |  |  |  |  | 
| 88 | 697 | 100 |  |  |  | 2291 | if ($roles) { | 
| 89 | 577 |  |  |  |  | 1983 | Moose::Util::apply_all_roles( $new_meta, @$roles ); | 
| 90 |  |  |  |  |  |  | } | 
| 91 |  |  |  |  |  |  |  | 
| 92 | 694 |  |  |  |  | 3846 | return $new_meta; | 
| 93 |  |  |  |  |  |  | } | 
| 94 |  |  |  |  |  |  |  | 
| 95 | 2661 |  |  | 2661 |  | 18078 | sub _meta_method_class { 'Moose::Meta::Method::Meta' } | 
| 96 |  |  |  |  |  |  |  | 
| 97 | 829 |  |  | 829 |  | 2920 | sub _anon_package_prefix { 'Moose::Meta::Class::__ANON__::SERIAL::' } | 
| 98 |  |  |  |  |  |  |  | 
| 99 |  |  |  |  |  |  | sub _anon_cache_key { | 
| 100 | 2721 |  |  | 2721 |  | 4289 | my $class = shift; | 
| 101 | 2721 |  |  |  |  | 6549 | my %options = @_; | 
| 102 |  |  |  |  |  |  |  | 
| 103 |  |  |  |  |  |  | my $superclass_key = join('|', | 
| 104 | 2721 |  | 50 |  |  | 4010 | map { $_->[0] } @{ Data::OptList::mkopt($options{superclasses} || []) } | 
|  | 4785 |  |  |  |  | 96807 |  | 
|  | 2721 |  |  |  |  | 9957 |  | 
| 105 |  |  |  |  |  |  | ); | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | my $roles = Data::OptList::mkopt(($options{roles} || []), { | 
| 108 |  |  |  |  |  |  | moniker  => 'role', | 
| 109 |  |  |  |  |  |  | name_test => sub { | 
| 110 | 21 | 100 | 66 | 21 |  | 621 | ! ref $_[0] or blessed($_[0]) && $_[0]->isa('Moose::Meta::Role') | 
| 111 |  |  |  |  |  |  | }, | 
| 112 | 2721 |  | 100 |  |  | 17373 | }); | 
| 113 |  |  |  |  |  |  |  | 
| 114 | 2721 |  |  |  |  | 74447 | my @role_keys; | 
| 115 | 2721 |  |  |  |  | 5677 | for my $role_spec (@$roles) { | 
| 116 | 2730 |  |  |  |  | 5035 | my ($role, $params) = @$role_spec; | 
| 117 | 2730 | 100 |  |  |  | 5461 | $params = { %$params } if $params; | 
| 118 |  |  |  |  |  |  |  | 
| 119 | 2730 | 100 |  |  |  | 7660 | my $key = blessed($role) ? $role->name : $role; | 
| 120 |  |  |  |  |  |  |  | 
| 121 | 2730 | 100 | 66 |  |  | 6930 | if ($params && %$params) { | 
| 122 |  |  |  |  |  |  | my $alias    = delete $params->{'-alias'} | 
| 123 | 7 |  | 50 |  |  | 38 | || delete $params->{'alias'} | 
| 124 |  |  |  |  |  |  | || {}; | 
| 125 |  |  |  |  |  |  | my $excludes = delete $params->{'-excludes'} | 
| 126 | 7 |  | 50 |  |  | 42 | || delete $params->{'excludes'} | 
| 127 |  |  |  |  |  |  | || []; | 
| 128 | 7 | 100 |  |  |  | 23 | $excludes = [$excludes] unless ref($excludes) eq 'ARRAY'; | 
| 129 |  |  |  |  |  |  |  | 
| 130 | 7 | 50 |  |  |  | 18 | if (%$params) { | 
| 131 | 0 |  |  |  |  | 0 | warn "Roles with parameters cannot be cached. Consider " | 
| 132 |  |  |  |  |  |  | . "applying the parameters before calling " | 
| 133 |  |  |  |  |  |  | . "create_anon_class, or using 'weaken => 0' instead"; | 
| 134 | 0 |  |  |  |  | 0 | return; | 
| 135 |  |  |  |  |  |  | } | 
| 136 |  |  |  |  |  |  |  | 
| 137 |  |  |  |  |  |  | my $alias_key = join('%', | 
| 138 | 7 |  |  |  |  | 23 | map { $_ => $alias->{$_} } sort keys %$alias | 
|  | 6 |  |  |  |  | 24 |  | 
| 139 |  |  |  |  |  |  | ); | 
| 140 | 7 |  |  |  |  | 20 | my $excludes_key = join('%', | 
| 141 |  |  |  |  |  |  | sort @$excludes | 
| 142 |  |  |  |  |  |  | ); | 
| 143 | 7 |  |  |  |  | 68 | $key .= '<' . join('+', 'a', $alias_key, 'e', $excludes_key) . '>'; | 
| 144 |  |  |  |  |  |  | } | 
| 145 |  |  |  |  |  |  |  | 
| 146 | 2730 |  |  |  |  | 5660 | push @role_keys, $key; | 
| 147 |  |  |  |  |  |  | } | 
| 148 |  |  |  |  |  |  |  | 
| 149 | 2721 |  |  |  |  | 6976 | my $role_key = join('|', sort @role_keys); | 
| 150 |  |  |  |  |  |  |  | 
| 151 |  |  |  |  |  |  | # Makes something like Super::Class|Super::Class::2=Role|Role::1 | 
| 152 | 2721 |  |  |  |  | 10724 | return join('=', $superclass_key, $role_key); | 
| 153 |  |  |  |  |  |  | } | 
| 154 |  |  |  |  |  |  |  | 
| 155 |  |  |  |  |  |  | sub reinitialize { | 
| 156 | 106 |  |  | 106 | 1 | 2602 | my $self = shift; | 
| 157 | 106 |  |  |  |  | 183 | my $pkg  = shift; | 
| 158 |  |  |  |  |  |  |  | 
| 159 | 106 | 100 |  |  |  | 429 | my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg); | 
| 160 |  |  |  |  |  |  |  | 
| 161 | 106 |  |  |  |  | 207 | my %existing_classes; | 
| 162 | 106 | 50 |  |  |  | 279 | if ($meta) { | 
| 163 | 106 |  |  |  |  | 470 | %existing_classes = map { $_ => $meta->$_() } qw( | 
|  | 636 |  |  |  |  | 6651 |  | 
| 164 |  |  |  |  |  |  | attribute_metaclass | 
| 165 |  |  |  |  |  |  | method_metaclass | 
| 166 |  |  |  |  |  |  | wrapped_method_metaclass | 
| 167 |  |  |  |  |  |  | instance_metaclass | 
| 168 |  |  |  |  |  |  | constructor_class | 
| 169 |  |  |  |  |  |  | destructor_class | 
| 170 |  |  |  |  |  |  | ); | 
| 171 |  |  |  |  |  |  | } | 
| 172 |  |  |  |  |  |  |  | 
| 173 | 106 |  |  |  |  | 839 | return $self->SUPER::reinitialize( | 
| 174 |  |  |  |  |  |  | $pkg, | 
| 175 |  |  |  |  |  |  | %existing_classes, | 
| 176 |  |  |  |  |  |  | @_, | 
| 177 |  |  |  |  |  |  | ); | 
| 178 |  |  |  |  |  |  | } | 
| 179 |  |  |  |  |  |  |  | 
| 180 |  |  |  |  |  |  | sub add_role { | 
| 181 | 1103 |  |  | 1103 | 1 | 3341 | my ($self, $role) = @_; | 
| 182 | 1103 | 100 | 100 |  |  | 10050 | (blessed($role) && $role->isa('Moose::Meta::Role')) | 
| 183 |  |  |  |  |  |  | || throw_exception( AddRoleTakesAMooseMetaRoleInstance => role_to_be_added => $role, | 
| 184 |  |  |  |  |  |  | class_name       => $self->name, | 
| 185 |  |  |  |  |  |  | ); | 
| 186 | 1100 |  |  |  |  | 3197 | push @{$self->roles} => $role; | 
|  | 1100 |  |  |  |  | 26309 |  | 
| 187 |  |  |  |  |  |  | } | 
| 188 |  |  |  |  |  |  |  | 
| 189 |  |  |  |  |  |  | sub role_applications { | 
| 190 | 9 |  |  | 9 | 1 | 22 | my ($self) = @_; | 
| 191 |  |  |  |  |  |  |  | 
| 192 | 9 |  |  |  |  | 12 | return @{$self->_get_role_applications}; | 
|  | 9 |  |  |  |  | 269 |  | 
| 193 |  |  |  |  |  |  | } | 
| 194 |  |  |  |  |  |  |  | 
| 195 |  |  |  |  |  |  | sub add_role_application { | 
| 196 | 1100 |  |  | 1100 | 1 | 2529 | my ($self, $application) = @_; | 
| 197 |  |  |  |  |  |  |  | 
| 198 | 1100 | 100 | 66 |  |  | 11630 | (blessed($application) && $application->isa('Moose::Meta::Role::Application::ToClass')) | 
| 199 |  |  |  |  |  |  | || throw_exception( InvalidRoleApplication => class_name  => $self->name, | 
| 200 |  |  |  |  |  |  | application => $application, | 
| 201 |  |  |  |  |  |  | ); | 
| 202 |  |  |  |  |  |  |  | 
| 203 | 1099 |  |  |  |  | 3043 | push @{$self->_get_role_applications} => $application; | 
|  | 1099 |  |  |  |  | 34910 |  | 
| 204 |  |  |  |  |  |  | } | 
| 205 |  |  |  |  |  |  |  | 
| 206 |  |  |  |  |  |  | sub calculate_all_roles { | 
| 207 | 352 |  |  | 352 | 1 | 684 | my $self = shift; | 
| 208 | 352 |  |  |  |  | 615 | my %seen; | 
| 209 | 352 |  |  |  |  | 588 | grep { !$seen{$_->name}++ } map { $_->calculate_all_roles } @{ $self->roles }; | 
|  | 541 |  |  |  |  | 2247 |  | 
|  | 335 |  |  |  |  | 3278 |  | 
|  | 352 |  |  |  |  | 9181 |  | 
| 210 |  |  |  |  |  |  | } | 
| 211 |  |  |  |  |  |  |  | 
| 212 |  |  |  |  |  |  | sub _roles_with_inheritance { | 
| 213 | 122 |  |  | 122 |  | 190 | my $self = shift; | 
| 214 | 122 |  |  |  |  | 140 | my %seen; | 
| 215 | 131 |  |  |  |  | 735 | grep { !$seen{$_->name}++ } | 
| 216 | 122 |  |  |  |  | 267 | map { Class::MOP::class_of($_)->can('roles') | 
| 217 | 1187 | 100 |  |  |  | 1842 | ? @{ Class::MOP::class_of($_)->roles } | 
|  | 131 |  |  |  |  | 242 |  | 
| 218 |  |  |  |  |  |  | : () } | 
| 219 |  |  |  |  |  |  | $self->linearized_isa; | 
| 220 |  |  |  |  |  |  | } | 
| 221 |  |  |  |  |  |  |  | 
| 222 |  |  |  |  |  |  | sub calculate_all_roles_with_inheritance { | 
| 223 | 22 |  |  | 22 | 1 | 38 | my $self = shift; | 
| 224 | 22 |  |  |  |  | 36 | my %seen; | 
| 225 | 33 |  |  |  |  | 216 | grep { !$seen{$_->name}++ } | 
| 226 | 22 | 100 |  |  |  | 58 | map { Class::MOP::class_of($_)->can('calculate_all_roles') | 
|  | 189 |  |  |  |  | 323 |  | 
| 227 |  |  |  |  |  |  | ? Class::MOP::class_of($_)->calculate_all_roles | 
| 228 |  |  |  |  |  |  | : () } | 
| 229 |  |  |  |  |  |  | $self->linearized_isa; | 
| 230 |  |  |  |  |  |  | } | 
| 231 |  |  |  |  |  |  |  | 
| 232 |  |  |  |  |  |  | sub does_role { | 
| 233 | 489 |  |  | 489 | 1 | 2052 | my ($self, $role_name) = @_; | 
| 234 |  |  |  |  |  |  |  | 
| 235 | 489 | 100 |  |  |  | 1105 | (defined $role_name) | 
| 236 |  |  |  |  |  |  | || throw_exception( RoleNameRequired => class_name => $self->name ); | 
| 237 |  |  |  |  |  |  |  | 
| 238 | 487 |  |  |  |  | 1426 | foreach my $class ($self->class_precedence_list) { | 
| 239 | 946 |  |  |  |  | 2044 | my $meta = Class::MOP::class_of($class); | 
| 240 |  |  |  |  |  |  | # when a Moose metaclass is itself extended with a role, | 
| 241 |  |  |  |  |  |  | # this check needs to be done since some items in the | 
| 242 |  |  |  |  |  |  | # class_precedence_list might in fact be Class::MOP | 
| 243 |  |  |  |  |  |  | # based still. | 
| 244 | 946 | 100 | 66 |  |  | 4294 | next unless $meta && $meta->can('roles'); | 
| 245 | 668 |  |  |  |  | 1012 | foreach my $role (@{$meta->roles}) { | 
|  | 668 |  |  |  |  | 18369 |  | 
| 246 | 459 | 100 |  |  |  | 1640 | return 1 if $role->does_role($role_name); | 
| 247 |  |  |  |  |  |  | } | 
| 248 |  |  |  |  |  |  | } | 
| 249 | 128 |  |  |  |  | 625 | return 0; | 
| 250 |  |  |  |  |  |  | } | 
| 251 |  |  |  |  |  |  |  | 
| 252 |  |  |  |  |  |  | sub excludes_role { | 
| 253 | 1130 |  |  | 1130 | 1 | 2951 | my ($self, $role_name) = @_; | 
| 254 |  |  |  |  |  |  |  | 
| 255 | 1130 | 100 |  |  |  | 3158 | (defined $role_name) | 
| 256 |  |  |  |  |  |  | || throw_exception( RoleNameRequired => class_name => $self->name ); | 
| 257 |  |  |  |  |  |  |  | 
| 258 | 1129 |  |  |  |  | 5140 | foreach my $class ($self->class_precedence_list) { | 
| 259 | 10465 |  |  |  |  | 18265 | my $meta = Class::MOP::class_of($class); | 
| 260 |  |  |  |  |  |  | # when a Moose metaclass is itself extended with a role, | 
| 261 |  |  |  |  |  |  | # this check needs to be done since some items in the | 
| 262 |  |  |  |  |  |  | # class_precedence_list might in fact be Class::MOP | 
| 263 |  |  |  |  |  |  | # based still. | 
| 264 | 10465 | 100 | 66 |  |  | 39291 | next unless $meta && $meta->can('roles'); | 
| 265 | 2193 |  |  |  |  | 3524 | foreach my $role (@{$meta->roles}) { | 
|  | 2193 |  |  |  |  | 54595 |  | 
| 266 | 116 | 100 |  |  |  | 478 | return 1 if $role->excludes_role($role_name); | 
| 267 |  |  |  |  |  |  | } | 
| 268 |  |  |  |  |  |  | } | 
| 269 | 1123 |  |  |  |  | 5298 | return 0; | 
| 270 |  |  |  |  |  |  | } | 
| 271 |  |  |  |  |  |  |  | 
| 272 |  |  |  |  |  |  | sub new_object { | 
| 273 | 3764 |  |  | 3764 | 1 | 6003 | my $self   = shift; | 
| 274 | 3764 | 100 |  |  |  | 8543 | my $params = @_ == 1 ? $_[0] : {@_}; | 
| 275 | 3764 |  |  |  |  | 12856 | my $object = $self->SUPER::new_object($params); | 
| 276 |  |  |  |  |  |  |  | 
| 277 | 2772 |  |  |  |  | 7961 | $self->_call_all_triggers($object, $params); | 
| 278 |  |  |  |  |  |  |  | 
| 279 | 2772 | 100 |  |  |  | 19525 | $object->BUILDALL($params) if $object->can('BUILDALL'); | 
| 280 |  |  |  |  |  |  |  | 
| 281 | 2763 |  |  |  |  | 15598 | return $object; | 
| 282 |  |  |  |  |  |  | } | 
| 283 |  |  |  |  |  |  |  | 
| 284 |  |  |  |  |  |  | sub _call_all_triggers { | 
| 285 | 2851 |  |  | 2851 |  | 5538 | my ($self, $object, $params) = @_; | 
| 286 |  |  |  |  |  |  |  | 
| 287 | 2851 |  |  |  |  | 6727 | foreach my $attr ( $self->get_all_attributes() ) { | 
| 288 |  |  |  |  |  |  |  | 
| 289 | 12837 | 100 | 100 |  |  | 161177 | next unless $attr->can('has_trigger') && $attr->has_trigger; | 
| 290 |  |  |  |  |  |  |  | 
| 291 | 51 |  |  |  |  | 174 | my $init_arg = $attr->init_arg; | 
| 292 | 51 | 50 |  |  |  | 170 | next unless defined $init_arg; | 
| 293 | 51 | 100 |  |  |  | 150 | next unless exists $params->{$init_arg}; | 
| 294 |  |  |  |  |  |  |  | 
| 295 |  |  |  |  |  |  | $attr->trigger->( | 
| 296 |  |  |  |  |  |  | $object, | 
| 297 |  |  |  |  |  |  | ( | 
| 298 |  |  |  |  |  |  | $attr->should_coerce | 
| 299 |  |  |  |  |  |  | ? $attr->get_read_method_ref->($object) | 
| 300 | 18 | 100 |  |  |  | 490 | : $params->{$init_arg} | 
| 301 |  |  |  |  |  |  | ), | 
| 302 |  |  |  |  |  |  | ); | 
| 303 |  |  |  |  |  |  | } | 
| 304 |  |  |  |  |  |  | } | 
| 305 |  |  |  |  |  |  |  | 
| 306 |  |  |  |  |  |  | sub _generate_fallback_constructor { | 
| 307 | 762 |  |  | 762 |  | 1433 | my $self = shift; | 
| 308 | 762 |  |  |  |  | 1582 | my ($class) = @_; | 
| 309 | 762 |  |  |  |  | 5833 | return $class . '->Moose::Object::new(@_)' | 
| 310 |  |  |  |  |  |  | } | 
| 311 |  |  |  |  |  |  |  | 
| 312 |  |  |  |  |  |  | sub _inline_params { | 
| 313 | 762 |  |  | 762 |  | 1499 | my $self = shift; | 
| 314 | 762 |  |  |  |  | 1817 | my ($params, $class) = @_; | 
| 315 |  |  |  |  |  |  | return ( | 
| 316 | 762 |  |  |  |  | 3135 | 'my ' . $params . ' = ', | 
| 317 |  |  |  |  |  |  | $self->_inline_BUILDARGS($class, '@_'), | 
| 318 |  |  |  |  |  |  | ';', | 
| 319 |  |  |  |  |  |  | ); | 
| 320 |  |  |  |  |  |  | } | 
| 321 |  |  |  |  |  |  |  | 
| 322 |  |  |  |  |  |  | sub _inline_BUILDARGS { | 
| 323 | 762 |  |  | 762 |  | 1889 | my $self = shift; | 
| 324 | 762 |  |  |  |  | 1696 | my ($class, $args) = @_; | 
| 325 |  |  |  |  |  |  |  | 
| 326 | 762 |  |  |  |  | 2897 | my $buildargs = $self->find_method_by_name("BUILDARGS"); | 
| 327 |  |  |  |  |  |  |  | 
| 328 | 762 | 100 | 100 |  |  | 4237 | if ($args eq '@_' | 
|  |  |  | 66 |  |  |  |  | 
| 329 |  |  |  |  |  |  | && (!$buildargs or $buildargs->body == \&Moose::Object::BUILDARGS)) { | 
| 330 |  |  |  |  |  |  | return ( | 
| 331 | 760 |  |  |  |  | 3574 | 'do {', | 
| 332 |  |  |  |  |  |  | 'my $params;', | 
| 333 |  |  |  |  |  |  | 'if (scalar @_ == 1) {', | 
| 334 |  |  |  |  |  |  | 'if (!defined($_[0]) || ref($_[0]) ne \'HASH\') {', | 
| 335 |  |  |  |  |  |  | $self->_inline_throw_exception( | 
| 336 |  |  |  |  |  |  | 'SingleParamsToNewMustBeHashRef' | 
| 337 |  |  |  |  |  |  | ) . ';', | 
| 338 |  |  |  |  |  |  | '}', | 
| 339 |  |  |  |  |  |  | '$params = { %{ $_[0] } };', | 
| 340 |  |  |  |  |  |  | '}', | 
| 341 |  |  |  |  |  |  | 'elsif (@_ % 2) {', | 
| 342 |  |  |  |  |  |  | 'Carp::carp(', | 
| 343 |  |  |  |  |  |  | '"The new() method for ' . $class . ' expects a ' | 
| 344 |  |  |  |  |  |  | . 'hash reference or a key/value list. You passed an ' | 
| 345 |  |  |  |  |  |  | . 'odd number of arguments"', | 
| 346 |  |  |  |  |  |  | ');', | 
| 347 |  |  |  |  |  |  | '$params = {@_, undef};', | 
| 348 |  |  |  |  |  |  | '}', | 
| 349 |  |  |  |  |  |  | 'else {', | 
| 350 |  |  |  |  |  |  | '$params = {@_};', | 
| 351 |  |  |  |  |  |  | '}', | 
| 352 |  |  |  |  |  |  | '$params;', | 
| 353 |  |  |  |  |  |  | '}', | 
| 354 |  |  |  |  |  |  | ); | 
| 355 |  |  |  |  |  |  | } | 
| 356 |  |  |  |  |  |  | else { | 
| 357 | 2 |  |  |  |  | 15 | return $class . '->BUILDARGS(' . $args . ')'; | 
| 358 |  |  |  |  |  |  | } | 
| 359 |  |  |  |  |  |  | } | 
| 360 |  |  |  |  |  |  |  | 
| 361 |  |  |  |  |  |  | sub _inline_slot_initializer { | 
| 362 | 2502 |  |  | 2502 |  | 3951 | my $self  = shift; | 
| 363 | 2502 |  |  |  |  | 5849 | my ($attr, $idx) = @_; | 
| 364 |  |  |  |  |  |  |  | 
| 365 |  |  |  |  |  |  | return ( | 
| 366 | 2502 |  |  |  |  | 9784 | '## ' . $attr->name, | 
| 367 |  |  |  |  |  |  | $self->_inline_check_required_attr($attr), | 
| 368 |  |  |  |  |  |  | $self->SUPER::_inline_slot_initializer(@_), | 
| 369 |  |  |  |  |  |  | ); | 
| 370 |  |  |  |  |  |  | } | 
| 371 |  |  |  |  |  |  |  | 
| 372 |  |  |  |  |  |  | sub _inline_check_required_attr { | 
| 373 | 2501 |  |  | 2501 |  | 4248 | my $self = shift; | 
| 374 | 2501 |  |  |  |  | 3963 | my ($attr) = @_; | 
| 375 |  |  |  |  |  |  |  | 
| 376 | 2501 | 100 |  |  |  | 8409 | return unless defined $attr->init_arg; | 
| 377 | 2492 | 100 | 100 |  |  | 88252 | return unless $attr->can('is_required') && $attr->is_required; | 
| 378 | 938 | 100 | 100 |  |  | 3320 | return if $attr->has_default || $attr->has_builder; | 
| 379 |  |  |  |  |  |  |  | 
| 380 | 925 |  |  |  |  | 7083 | my $throw = $self->_inline_throw_exception( | 
| 381 |  |  |  |  |  |  | 'AttributeIsRequired', | 
| 382 |  |  |  |  |  |  | sprintf( | 
| 383 |  |  |  |  |  |  | <<'EOF', quotemeta( $attr->name ), quotemeta( $attr->init_arg ) ), ); | 
| 384 |  |  |  |  |  |  | params             => $params, | 
| 385 |  |  |  |  |  |  | class_name         => $class_name, | 
| 386 |  |  |  |  |  |  | attribute_name     => "%s", | 
| 387 |  |  |  |  |  |  | attribute_init_arg => "%s", | 
| 388 |  |  |  |  |  |  | EOF | 
| 389 |  |  |  |  |  |  |  | 
| 390 | 925 |  |  |  |  | 6060 | return sprintf( <<'EOF', quotemeta( $attr->init_arg ), $throw ) | 
| 391 |  |  |  |  |  |  | if ( !exists $params->{"%s"} ) { | 
| 392 |  |  |  |  |  |  | %s; | 
| 393 |  |  |  |  |  |  | } | 
| 394 |  |  |  |  |  |  | EOF | 
| 395 |  |  |  |  |  |  | } | 
| 396 |  |  |  |  |  |  |  | 
| 397 |  |  |  |  |  |  | # XXX: these two are duplicated from cmop, because we have to pass the tc stuff | 
| 398 |  |  |  |  |  |  | # through to _inline_set_value - this should probably be fixed, but i'm not | 
| 399 |  |  |  |  |  |  | # quite sure how. -doy | 
| 400 |  |  |  |  |  |  | sub _inline_init_attr_from_constructor { | 
| 401 | 2493 |  |  | 2493 |  | 3799 | my $self = shift; | 
| 402 | 2493 |  |  |  |  | 4464 | my ($attr, $idx) = @_; | 
| 403 |  |  |  |  |  |  |  | 
| 404 | 2493 |  |  |  |  | 13937 | my @initial_value = $attr->_inline_set_value( | 
| 405 |  |  |  |  |  |  | '$instance', | 
| 406 |  |  |  |  |  |  | '$params->{\'' . $attr->init_arg . '\'}', | 
| 407 |  |  |  |  |  |  | '$type_constraint_bodies[' . $idx . ']', | 
| 408 |  |  |  |  |  |  | '$type_coercions[' . $idx . ']', | 
| 409 |  |  |  |  |  |  | '$type_constraint_messages[' . $idx . ']', | 
| 410 |  |  |  |  |  |  | 'for constructor', | 
| 411 |  |  |  |  |  |  | ); | 
| 412 |  |  |  |  |  |  |  | 
| 413 | 2493 | 100 |  |  |  | 8248 | push @initial_value, ( | 
| 414 |  |  |  |  |  |  | '$attrs->[' . $idx . ']->set_initial_value(', | 
| 415 |  |  |  |  |  |  | '$instance,', | 
| 416 |  |  |  |  |  |  | $attr->_inline_instance_get('$instance'), | 
| 417 |  |  |  |  |  |  | ');', | 
| 418 |  |  |  |  |  |  | ) if $attr->has_initializer; | 
| 419 |  |  |  |  |  |  |  | 
| 420 | 2493 |  |  |  |  | 8328 | return @initial_value; | 
| 421 |  |  |  |  |  |  | } | 
| 422 |  |  |  |  |  |  |  | 
| 423 |  |  |  |  |  |  | sub _inline_init_attr_from_default { | 
| 424 | 2502 |  |  | 2502 |  | 3830 | my $self = shift; | 
| 425 | 2502 |  |  |  |  | 5059 | my ($attr, $idx) = @_; | 
| 426 |  |  |  |  |  |  |  | 
| 427 | 2502 | 100 | 100 |  |  | 75086 | return if $attr->can('is_lazy') && $attr->is_lazy; | 
| 428 | 1223 |  |  |  |  | 4783 | my $default = $self->_inline_default_value($attr, $idx); | 
| 429 | 1223 | 100 |  |  |  | 4347 | return unless $default; | 
| 430 |  |  |  |  |  |  |  | 
| 431 | 141 |  |  |  |  | 918 | my @initial_value = ( | 
| 432 |  |  |  |  |  |  | 'my $default = ' . $default . ';', | 
| 433 |  |  |  |  |  |  | $attr->_inline_set_value( | 
| 434 |  |  |  |  |  |  | '$instance', | 
| 435 |  |  |  |  |  |  | '$default', | 
| 436 |  |  |  |  |  |  | '$type_constraint_bodies[' . $idx . ']', | 
| 437 |  |  |  |  |  |  | '$type_coercions[' . $idx . ']', | 
| 438 |  |  |  |  |  |  | '$type_constraint_messages[' . $idx . ']', | 
| 439 |  |  |  |  |  |  | 'for constructor', | 
| 440 |  |  |  |  |  |  | ), | 
| 441 |  |  |  |  |  |  | ); | 
| 442 |  |  |  |  |  |  |  | 
| 443 | 141 | 50 |  |  |  | 518 | push @initial_value, ( | 
| 444 |  |  |  |  |  |  | '$attrs->[' . $idx . ']->set_initial_value(', | 
| 445 |  |  |  |  |  |  | '$instance,', | 
| 446 |  |  |  |  |  |  | $attr->_inline_instance_get('$instance'), | 
| 447 |  |  |  |  |  |  | ');', | 
| 448 |  |  |  |  |  |  | ) if $attr->has_initializer; | 
| 449 |  |  |  |  |  |  |  | 
| 450 | 141 |  |  |  |  | 697 | return @initial_value; | 
| 451 |  |  |  |  |  |  | } | 
| 452 |  |  |  |  |  |  |  | 
| 453 |  |  |  |  |  |  | sub _inline_extra_init { | 
| 454 | 762 |  |  | 762 |  | 1520 | my $self = shift; | 
| 455 |  |  |  |  |  |  | return ( | 
| 456 | 762 |  |  |  |  | 2781 | $self->_inline_triggers, | 
| 457 |  |  |  |  |  |  | $self->_inline_BUILDALL, | 
| 458 |  |  |  |  |  |  | ); | 
| 459 |  |  |  |  |  |  | } | 
| 460 |  |  |  |  |  |  |  | 
| 461 |  |  |  |  |  |  | sub _inline_triggers { | 
| 462 | 762 |  |  | 762 |  | 1333 | my $self = shift; | 
| 463 | 762 |  |  |  |  | 1835 | my @trigger_calls; | 
| 464 |  |  |  |  |  |  |  | 
| 465 | 762 |  |  |  |  | 2451 | my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes; | 
|  | 3075 |  |  |  |  | 8170 |  | 
| 466 | 762 |  |  |  |  | 3317 | for my $i (0 .. $#attrs) { | 
| 467 | 2502 |  |  |  |  | 4074 | my $attr = $attrs[$i]; | 
| 468 |  |  |  |  |  |  |  | 
| 469 | 2502 | 100 | 100 |  |  | 76042 | next unless $attr->can('has_trigger') && $attr->has_trigger; | 
| 470 |  |  |  |  |  |  |  | 
| 471 | 13 |  |  |  |  | 51 | my $init_arg = $attr->init_arg; | 
| 472 | 13 | 50 |  |  |  | 47 | next unless defined $init_arg; | 
| 473 |  |  |  |  |  |  |  | 
| 474 | 13 |  |  |  |  | 90 | push @trigger_calls, | 
| 475 |  |  |  |  |  |  | 'if (exists $params->{\'' . $init_arg . '\'}) {', | 
| 476 |  |  |  |  |  |  | '$triggers->[' . $i . ']->(', | 
| 477 |  |  |  |  |  |  | '$instance,', | 
| 478 |  |  |  |  |  |  | $attr->_inline_instance_get('$instance') . ',', | 
| 479 |  |  |  |  |  |  | ');', | 
| 480 |  |  |  |  |  |  | '}'; | 
| 481 |  |  |  |  |  |  | } | 
| 482 |  |  |  |  |  |  |  | 
| 483 | 762 |  |  |  |  | 3468 | return @trigger_calls; | 
| 484 |  |  |  |  |  |  | } | 
| 485 |  |  |  |  |  |  |  | 
| 486 |  |  |  |  |  |  | sub _inline_BUILDALL { | 
| 487 | 762 |  |  | 762 |  | 1479 | my $self = shift; | 
| 488 |  |  |  |  |  |  |  | 
| 489 | 762 |  |  |  |  | 5083 | my @methods = reverse $self->find_all_methods_by_name('BUILD'); | 
| 490 | 762 | 100 |  |  |  | 3103 | return () unless @methods; | 
| 491 |  |  |  |  |  |  |  | 
| 492 | 625 |  |  |  |  | 1241 | my @BUILD_calls; | 
| 493 |  |  |  |  |  |  |  | 
| 494 | 625 |  |  |  |  | 1400 | foreach my $method (@methods) { | 
| 495 |  |  |  |  |  |  | push @BUILD_calls, | 
| 496 | 638 |  |  |  |  | 2378 | '$instance->' . $method->{class} . '::BUILD($params);'; | 
| 497 |  |  |  |  |  |  | } | 
| 498 |  |  |  |  |  |  |  | 
| 499 |  |  |  |  |  |  | return ( | 
| 500 | 625 |  |  |  |  | 5616 | 'if (!$params->{__no_BUILD__}) {', | 
| 501 |  |  |  |  |  |  | @BUILD_calls, | 
| 502 |  |  |  |  |  |  | '}', | 
| 503 |  |  |  |  |  |  | ); | 
| 504 |  |  |  |  |  |  | } | 
| 505 |  |  |  |  |  |  |  | 
| 506 |  |  |  |  |  |  | sub _eval_environment { | 
| 507 | 763 |  |  | 763 |  | 1586 | my $self = shift; | 
| 508 |  |  |  |  |  |  |  | 
| 509 | 763 |  |  |  |  | 2658 | my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes; | 
|  | 3097 |  |  |  |  | 8340 |  | 
| 510 |  |  |  |  |  |  |  | 
| 511 |  |  |  |  |  |  | my $triggers = [ | 
| 512 | 763 | 100 | 100 |  |  | 2039 | map { $_->can('has_trigger') && $_->has_trigger ? $_->trigger : undef } | 
|  | 2502 |  |  |  |  | 78206 |  | 
| 513 |  |  |  |  |  |  | @attrs | 
| 514 |  |  |  |  |  |  | ]; | 
| 515 |  |  |  |  |  |  |  | 
| 516 |  |  |  |  |  |  | # We need to check if the attribute ->can('type_constraint') | 
| 517 |  |  |  |  |  |  | # since we may be trying to immutabilize a Moose meta class, | 
| 518 |  |  |  |  |  |  | # which in turn has attributes which are Class::MOP::Attribute | 
| 519 |  |  |  |  |  |  | # objects, rather than Moose::Meta::Attribute. And | 
| 520 |  |  |  |  |  |  | # Class::MOP::Attribute attributes have no type constraints. | 
| 521 |  |  |  |  |  |  | # However we need to make sure we leave an undef value there | 
| 522 |  |  |  |  |  |  | # because the inlined code is using the index of the attributes | 
| 523 |  |  |  |  |  |  | # to determine where to find the type constraint | 
| 524 |  |  |  |  |  |  |  | 
| 525 |  |  |  |  |  |  | my @type_constraints = map { | 
| 526 | 763 | 100 |  |  |  | 2673 | $_->can('type_constraint') ? $_->type_constraint : undef | 
|  | 2502 |  |  |  |  | 65272 |  | 
| 527 |  |  |  |  |  |  | } @attrs; | 
| 528 |  |  |  |  |  |  |  | 
| 529 |  |  |  |  |  |  | my @type_constraint_bodies = map { | 
| 530 | 763 | 100 |  |  |  | 2829 | defined $_ ? $_->_compiled_type_constraint : undef; | 
|  | 2502 |  |  |  |  | 75892 |  | 
| 531 |  |  |  |  |  |  | } @type_constraints; | 
| 532 |  |  |  |  |  |  |  | 
| 533 |  |  |  |  |  |  | my @type_coercions = map { | 
| 534 | 763 | 100 | 100 |  |  | 1810 | defined $_ && $_->has_coercion | 
|  | 2502 |  |  |  |  | 67125 |  | 
| 535 |  |  |  |  |  |  | ? $_->coercion->_compiled_type_coercion | 
| 536 |  |  |  |  |  |  | : undef | 
| 537 |  |  |  |  |  |  | } @type_constraints; | 
| 538 |  |  |  |  |  |  |  | 
| 539 |  |  |  |  |  |  | my @type_constraint_messages = map { | 
| 540 | 763 | 50 |  |  |  | 2236 | defined $_ | 
|  | 2502 | 100 |  |  |  | 65017 |  | 
| 541 |  |  |  |  |  |  | ? ($_->has_message ? $_->message : $_->_default_message) | 
| 542 |  |  |  |  |  |  | : undef | 
| 543 |  |  |  |  |  |  | } @type_constraints; | 
| 544 |  |  |  |  |  |  |  | 
| 545 |  |  |  |  |  |  | return { | 
| 546 | 763 |  |  |  |  | 3845 | %{ $self->SUPER::_eval_environment }, | 
| 547 | 2501 | 50 |  | 2501 |  | 7702 | ((any { defined && $_->has_initializer } @attrs) | 
| 548 |  |  |  |  |  |  | ? ('$attrs' => \[@attrs]) | 
| 549 |  |  |  |  |  |  | : ()), | 
| 550 |  |  |  |  |  |  | '$triggers' => \$triggers, | 
| 551 |  |  |  |  |  |  | '@type_coercions' => \@type_coercions, | 
| 552 |  |  |  |  |  |  | '@type_constraint_bodies' => \@type_constraint_bodies, | 
| 553 |  |  |  |  |  |  | '@type_constraint_messages' => \@type_constraint_messages, | 
| 554 | 763 | 100 |  |  |  | 1533 | ( map { defined($_) ? %{ $_->inline_environment } : () } | 
|  | 2502 | 100 |  |  |  | 5271 |  | 
|  | 2426 |  |  |  |  | 5503 |  | 
| 555 |  |  |  |  |  |  | @type_constraints ), | 
| 556 |  |  |  |  |  |  | # pretty sure this is only going to be closed over if you use a custom | 
| 557 |  |  |  |  |  |  | # error class at this point, but we should still get rid of this | 
| 558 |  |  |  |  |  |  | # at some point | 
| 559 |  |  |  |  |  |  | '$meta'  => \$self, | 
| 560 |  |  |  |  |  |  | '$class_name' => \($self->name), | 
| 561 |  |  |  |  |  |  | }; | 
| 562 |  |  |  |  |  |  | } | 
| 563 |  |  |  |  |  |  |  | 
| 564 |  |  |  |  |  |  | sub superclasses { | 
| 565 | 15659 |  |  | 15659 | 1 | 27863 | my $self = shift; | 
| 566 | 15659 |  |  |  |  | 47317 | my $supers = Data::OptList::mkopt(\@_); | 
| 567 | 15659 |  |  |  |  | 315321 | foreach my $super (@{ $supers }) { | 
|  | 15659 |  |  |  |  | 31082 |  | 
| 568 | 3168 |  |  |  |  | 5273 | my ($name, $opts) = @{ $super }; | 
|  | 3168 |  |  |  |  | 6731 |  | 
| 569 | 3168 |  |  |  |  | 12530 | Moose::Util::_load_user_class($name, $opts); | 
| 570 | 3167 |  |  |  |  | 163561 | my $meta = Class::MOP::class_of($name); | 
| 571 | 3167 | 100 | 100 |  |  | 28225 | throw_exception( CanExtendOnlyClasses => role_name => $meta->name ) | 
| 572 |  |  |  |  |  |  | if $meta && $meta->isa('Moose::Meta::Role') | 
| 573 |  |  |  |  |  |  | } | 
| 574 | 15656 |  |  |  |  | 23150 | return $self->SUPER::superclasses(map { $_->[0] } @{ $supers }); | 
|  | 3164 |  |  |  |  | 11558 |  | 
|  | 15656 |  |  |  |  | 41144 |  | 
| 575 |  |  |  |  |  |  | } | 
| 576 |  |  |  |  |  |  |  | 
| 577 |  |  |  |  |  |  | ### --------------------------------------------- | 
| 578 |  |  |  |  |  |  |  | 
| 579 |  |  |  |  |  |  | sub add_attribute { | 
| 580 | 2376 |  |  | 2376 | 1 | 16922 | my $self = shift; | 
| 581 | 2376 | 100 | 66 |  |  | 15530 | my $attr = | 
| 582 |  |  |  |  |  |  | (blessed $_[0] && $_[0]->isa('Class::MOP::Attribute') | 
| 583 |  |  |  |  |  |  | ? $_[0] | 
| 584 |  |  |  |  |  |  | : $self->_process_attribute(@_)); | 
| 585 | 2336 |  |  |  |  | 12764 | $self->SUPER::add_attribute($attr); | 
| 586 |  |  |  |  |  |  | # it may be a Class::MOP::Attribute, theoretically, which doesn't have | 
| 587 |  |  |  |  |  |  | # 'bare' and doesn't implement this method | 
| 588 | 2314 | 100 |  |  |  | 11659 | if ($attr->can('_check_associated_methods')) { | 
| 589 | 2311 |  |  |  |  | 6832 | $attr->_check_associated_methods; | 
| 590 |  |  |  |  |  |  | } | 
| 591 | 2314 |  |  |  |  | 12913 | return $attr; | 
| 592 |  |  |  |  |  |  | } | 
| 593 |  |  |  |  |  |  |  | 
| 594 |  |  |  |  |  |  | sub add_override_method_modifier { | 
| 595 | 1014 |  |  | 1014 | 1 | 2198 | my ($self, $name, $method, $_super_package) = @_; | 
| 596 |  |  |  |  |  |  |  | 
| 597 | 1014 |  |  |  |  | 2538 | my $existing_method = $self->get_method($name); | 
| 598 | 1014 | 100 |  |  |  | 2276 | (!$existing_method) | 
| 599 |  |  |  |  |  |  | || throw_exception( CannotOverrideLocalMethodIsPresent => class_name => $self->name, | 
| 600 |  |  |  |  |  |  | method     => $existing_method, | 
| 601 |  |  |  |  |  |  | ); | 
| 602 | 1012 |  |  |  |  | 4904 | $self->add_method($name => Moose::Meta::Method::Overridden->new( | 
| 603 |  |  |  |  |  |  | method  => $method, | 
| 604 |  |  |  |  |  |  | class   => $self, | 
| 605 |  |  |  |  |  |  | package => $_super_package, # need this for roles | 
| 606 |  |  |  |  |  |  | name    => $name, | 
| 607 |  |  |  |  |  |  | )); | 
| 608 |  |  |  |  |  |  | } | 
| 609 |  |  |  |  |  |  |  | 
| 610 |  |  |  |  |  |  | sub add_augment_method_modifier { | 
| 611 | 16 |  |  | 16 | 1 | 41 | my ($self, $name, $method) = @_; | 
| 612 | 16 |  |  |  |  | 88 | my $existing_method = $self->get_method($name); | 
| 613 | 16 | 100 |  |  |  | 43 | throw_exception( CannotAugmentIfLocalMethodPresent => class_name => $self->name, | 
| 614 |  |  |  |  |  |  | method     => $existing_method, | 
| 615 |  |  |  |  |  |  | ) | 
| 616 |  |  |  |  |  |  | if( $existing_method ); | 
| 617 |  |  |  |  |  |  |  | 
| 618 | 14 |  |  |  |  | 97 | $self->add_method($name => Moose::Meta::Method::Augmented->new( | 
| 619 |  |  |  |  |  |  | method  => $method, | 
| 620 |  |  |  |  |  |  | class   => $self, | 
| 621 |  |  |  |  |  |  | name    => $name, | 
| 622 |  |  |  |  |  |  | )); | 
| 623 |  |  |  |  |  |  | } | 
| 624 |  |  |  |  |  |  |  | 
| 625 |  |  |  |  |  |  | ## Private Utility methods ... | 
| 626 |  |  |  |  |  |  |  | 
| 627 |  |  |  |  |  |  | sub _find_next_method_by_name_which_is_not_overridden { | 
| 628 | 1 |  |  | 1 |  | 3 | my ($self, $name) = @_; | 
| 629 | 1 |  |  |  |  | 6 | foreach my $method ($self->find_all_methods_by_name($name)) { | 
| 630 |  |  |  |  |  |  | return $method->{code} | 
| 631 | 2 | 100 | 66 |  |  | 16 | if blessed($method->{code}) && !$method->{code}->isa('Moose::Meta::Method::Overridden'); | 
| 632 |  |  |  |  |  |  | } | 
| 633 | 0 |  |  |  |  | 0 | return undef; | 
| 634 |  |  |  |  |  |  | } | 
| 635 |  |  |  |  |  |  |  | 
| 636 |  |  |  |  |  |  | ## Metaclass compatibility | 
| 637 |  |  |  |  |  |  |  | 
| 638 |  |  |  |  |  |  | sub _base_metaclasses { | 
| 639 | 6240 |  |  | 6240 |  | 9614 | my $self = shift; | 
| 640 | 6240 |  |  |  |  | 15500 | my %metaclasses = $self->SUPER::_base_metaclasses; | 
| 641 | 6240 |  |  |  |  | 17833 | for my $class (keys %metaclasses) { | 
| 642 | 37440 |  |  |  |  | 105039 | $metaclasses{$class} =~ s/^Class::MOP/Moose::Meta/; | 
| 643 |  |  |  |  |  |  | } | 
| 644 |  |  |  |  |  |  | return ( | 
| 645 | 6240 |  |  |  |  | 31891 | %metaclasses, | 
| 646 |  |  |  |  |  |  | ); | 
| 647 |  |  |  |  |  |  | } | 
| 648 |  |  |  |  |  |  |  | 
| 649 |  |  |  |  |  |  | sub _fix_class_metaclass_incompatibility { | 
| 650 | 38 |  |  | 38 |  | 64 | my $self = shift; | 
| 651 | 38 |  |  |  |  | 69 | my ($super_meta) = @_; | 
| 652 |  |  |  |  |  |  |  | 
| 653 | 38 |  |  |  |  | 154 | $self->SUPER::_fix_class_metaclass_incompatibility(@_); | 
| 654 |  |  |  |  |  |  |  | 
| 655 | 35 | 50 |  |  |  | 161 | if ($self->_class_metaclass_can_be_made_compatible($super_meta)) { | 
| 656 | 0 | 0 |  |  |  | 0 | ($self->is_pristine) | 
| 657 |  |  |  |  |  |  | || throw_exception( CannotFixMetaclassCompatibility => class      => $self, | 
| 658 |  |  |  |  |  |  | superclass => $super_meta | 
| 659 |  |  |  |  |  |  | ); | 
| 660 | 0 |  |  |  |  | 0 | my $super_meta_name = $super_meta->_real_ref_name; | 
| 661 | 0 |  |  |  |  | 0 | my $class_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass(blessed($self), $super_meta_name); | 
| 662 | 0 |  |  |  |  | 0 | my $new_self = $class_meta_subclass_meta_name->reinitialize( | 
| 663 |  |  |  |  |  |  | $self->name, | 
| 664 |  |  |  |  |  |  | ); | 
| 665 |  |  |  |  |  |  |  | 
| 666 | 0 |  |  |  |  | 0 | $self->_replace_self( $new_self, $class_meta_subclass_meta_name ); | 
| 667 |  |  |  |  |  |  | } | 
| 668 |  |  |  |  |  |  | } | 
| 669 |  |  |  |  |  |  |  | 
| 670 |  |  |  |  |  |  | sub _fix_single_metaclass_incompatibility { | 
| 671 | 124 |  |  | 124 |  | 183 | my $self = shift; | 
| 672 | 124 |  |  |  |  | 198 | my ($metaclass_type, $super_meta) = @_; | 
| 673 |  |  |  |  |  |  |  | 
| 674 | 124 |  |  |  |  | 382 | $self->SUPER::_fix_single_metaclass_incompatibility(@_); | 
| 675 |  |  |  |  |  |  |  | 
| 676 | 124 | 50 |  |  |  | 290 | if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) { | 
| 677 | 0 | 0 |  |  |  | 0 | ($self->is_pristine) | 
| 678 |  |  |  |  |  |  | || throw_exception( CannotFixMetaclassCompatibility => class          => $self, | 
| 679 |  |  |  |  |  |  | superclass     => $super_meta, | 
| 680 |  |  |  |  |  |  | metaclass_type => $metaclass_type | 
| 681 |  |  |  |  |  |  | ); | 
| 682 | 0 |  |  |  |  | 0 | my $super_meta_name = $super_meta->_real_ref_name; | 
| 683 | 0 |  |  |  |  | 0 | my $class_specific_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass($self->$metaclass_type, $super_meta->$metaclass_type); | 
| 684 | 0 |  |  |  |  | 0 | my $new_self = $super_meta->reinitialize( | 
| 685 |  |  |  |  |  |  | $self->name, | 
| 686 |  |  |  |  |  |  | $metaclass_type => $class_specific_meta_subclass_meta_name, | 
| 687 |  |  |  |  |  |  | ); | 
| 688 |  |  |  |  |  |  |  | 
| 689 | 0 |  |  |  |  | 0 | $self->_replace_self( $new_self, $super_meta_name ); | 
| 690 |  |  |  |  |  |  | } | 
| 691 |  |  |  |  |  |  | } | 
| 692 |  |  |  |  |  |  |  | 
| 693 |  |  |  |  |  |  | sub _replace_self { | 
| 694 | 0 |  |  | 0 |  | 0 | my $self      = shift; | 
| 695 | 0 |  |  |  |  | 0 | my ( $new_self, $new_class)   = @_; | 
| 696 |  |  |  |  |  |  |  | 
| 697 | 0 |  |  |  |  | 0 | %$self = %$new_self; | 
| 698 | 0 |  |  |  |  | 0 | bless $self, $new_class; | 
| 699 |  |  |  |  |  |  |  | 
| 700 |  |  |  |  |  |  | # We need to replace the cached metaclass instance or else when it goes | 
| 701 |  |  |  |  |  |  | # out of scope Class::MOP::Class destroy's the namespace for the | 
| 702 |  |  |  |  |  |  | # metaclass's class, causing much havoc. | 
| 703 | 0 |  |  |  |  | 0 | my $weaken = Class::MOP::metaclass_is_weak( $self->name ); | 
| 704 | 0 |  |  |  |  | 0 | Class::MOP::store_metaclass_by_name( $self->name, $self ); | 
| 705 | 0 | 0 |  |  |  | 0 | Class::MOP::weaken_metaclass( $self->name ) if $weaken; | 
| 706 |  |  |  |  |  |  | } | 
| 707 |  |  |  |  |  |  |  | 
| 708 |  |  |  |  |  |  | sub _process_attribute { | 
| 709 | 1704 |  |  | 1704 |  | 5606 | my ( $self, $name, @args ) = @_; | 
| 710 |  |  |  |  |  |  |  | 
| 711 | 1704 | 50 | 33 |  |  | 5744 | @args = %{$args[0]} if scalar @args == 1 && ref($args[0]) eq 'HASH'; | 
|  | 0 |  |  |  |  | 0 |  | 
| 712 |  |  |  |  |  |  |  | 
| 713 | 1704 | 100 | 100 |  |  | 6818 | if (($name || '') =~ /^\+(.*)/) { | 
| 714 | 40 |  |  |  |  | 136 | return $self->_process_inherited_attribute($1, @args); | 
| 715 |  |  |  |  |  |  | } | 
| 716 |  |  |  |  |  |  | else { | 
| 717 | 1664 |  |  |  |  | 4982 | return $self->_process_new_attribute($name, @args); | 
| 718 |  |  |  |  |  |  | } | 
| 719 |  |  |  |  |  |  | } | 
| 720 |  |  |  |  |  |  |  | 
| 721 |  |  |  |  |  |  | sub _process_new_attribute { | 
| 722 | 1664 |  |  | 1664 |  | 4779 | my ( $self, $name, @args ) = @_; | 
| 723 |  |  |  |  |  |  |  | 
| 724 | 1664 |  |  |  |  | 12715 | $self->attribute_metaclass->interpolate_class_and_new($name, @args); | 
| 725 |  |  |  |  |  |  | } | 
| 726 |  |  |  |  |  |  |  | 
| 727 |  |  |  |  |  |  | sub _process_inherited_attribute { | 
| 728 | 40 |  |  | 40 |  | 183 | my ($self, $attr_name, %options) = @_; | 
| 729 |  |  |  |  |  |  |  | 
| 730 | 40 |  |  |  |  | 162 | my $inherited_attr = $self->find_attribute_by_name($attr_name); | 
| 731 | 40 | 100 |  |  |  | 163 | (defined $inherited_attr) | 
| 732 |  |  |  |  |  |  | || throw_exception( NoAttributeFoundInSuperClass => class_name     => $self->name, | 
| 733 |  |  |  |  |  |  | attribute_name => $attr_name, | 
| 734 |  |  |  |  |  |  | params         => \%options | 
| 735 |  |  |  |  |  |  | ); | 
| 736 | 36 | 50 |  |  |  | 129 | if ($inherited_attr->isa('Moose::Meta::Attribute')) { | 
| 737 | 36 |  |  |  |  | 142 | return $inherited_attr->clone_and_inherit_options(%options); | 
| 738 |  |  |  |  |  |  | } | 
| 739 |  |  |  |  |  |  | else { | 
| 740 |  |  |  |  |  |  | # NOTE: | 
| 741 |  |  |  |  |  |  | # kind of a kludge to handle Class::MOP::Attributes | 
| 742 | 0 |  |  |  |  | 0 | return $inherited_attr->Moose::Meta::Attribute::clone_and_inherit_options(%options); | 
| 743 |  |  |  |  |  |  | } | 
| 744 |  |  |  |  |  |  | } | 
| 745 |  |  |  |  |  |  |  | 
| 746 |  |  |  |  |  |  | # reinitialization support | 
| 747 |  |  |  |  |  |  |  | 
| 748 |  |  |  |  |  |  | sub _restore_metaobjects_from { | 
| 749 | 105 |  |  | 105 |  | 217 | my $self = shift; | 
| 750 | 105 |  |  |  |  | 218 | my ($old_meta) = @_; | 
| 751 |  |  |  |  |  |  |  | 
| 752 | 105 |  |  |  |  | 424 | $self->SUPER::_restore_metaobjects_from($old_meta); | 
| 753 |  |  |  |  |  |  |  | 
| 754 | 103 |  |  |  |  | 212 | for my $role ( @{ $old_meta->roles } ) { | 
|  | 103 |  |  |  |  | 3224 |  | 
| 755 | 8 |  |  |  |  | 30 | $self->add_role($role); | 
| 756 |  |  |  |  |  |  | } | 
| 757 |  |  |  |  |  |  |  | 
| 758 | 103 |  |  |  |  | 606 | for my $application ( @{ $old_meta->_get_role_applications } ) { | 
|  | 103 |  |  |  |  | 3215 |  | 
| 759 | 8 |  |  |  |  | 214 | $application->class($self); | 
| 760 | 8 |  |  |  |  | 23 | $self->add_role_application ($application); | 
| 761 |  |  |  |  |  |  | } | 
| 762 |  |  |  |  |  |  | } | 
| 763 |  |  |  |  |  |  |  | 
| 764 |  |  |  |  |  |  | ## Immutability | 
| 765 |  |  |  |  |  |  |  | 
| 766 |  |  |  |  |  |  | sub _immutable_options { | 
| 767 | 778 |  |  | 778 |  | 1978 | my ( $self, @args ) = @_; | 
| 768 |  |  |  |  |  |  |  | 
| 769 | 778 |  |  |  |  | 3364 | $self->SUPER::_immutable_options( | 
| 770 |  |  |  |  |  |  | inline_destructor => 1, | 
| 771 |  |  |  |  |  |  |  | 
| 772 |  |  |  |  |  |  | # Moose always does this when an attribute is created | 
| 773 |  |  |  |  |  |  | inline_accessors => 0, | 
| 774 |  |  |  |  |  |  |  | 
| 775 |  |  |  |  |  |  | @args, | 
| 776 |  |  |  |  |  |  | ); | 
| 777 |  |  |  |  |  |  | } | 
| 778 |  |  |  |  |  |  |  | 
| 779 |  |  |  |  |  |  | sub _fixup_attributes_after_rebless { | 
| 780 | 83 |  |  | 83 |  | 158 | my $self = shift; | 
| 781 | 83 |  |  |  |  | 172 | my ($instance, $rebless_from, %params) = @_; | 
| 782 |  |  |  |  |  |  |  | 
| 783 | 83 |  |  |  |  | 432 | $self->SUPER::_fixup_attributes_after_rebless( | 
| 784 |  |  |  |  |  |  | $instance, | 
| 785 |  |  |  |  |  |  | $rebless_from, | 
| 786 |  |  |  |  |  |  | %params | 
| 787 |  |  |  |  |  |  | ); | 
| 788 |  |  |  |  |  |  |  | 
| 789 | 79 |  |  |  |  | 320 | $self->_call_all_triggers( $instance, \%params ); | 
| 790 |  |  |  |  |  |  | } | 
| 791 |  |  |  |  |  |  |  | 
| 792 |  |  |  |  |  |  | ## ------------------------------------------------- | 
| 793 |  |  |  |  |  |  |  | 
| 794 |  |  |  |  |  |  | our $error_level; | 
| 795 |  |  |  |  |  |  |  | 
| 796 |  |  |  |  |  |  | sub _inline_throw_exception { | 
| 797 | 1685 |  |  | 1685 |  | 4021 | my ( $self, $exception_type, $throw_args ) = @_; | 
| 798 | 1685 |  | 100 |  |  | 15850 | return 'die Module::Runtime::use_module("Moose::Exception::' . $exception_type . '")->new(' . ($throw_args || '') . ')'; | 
| 799 |  |  |  |  |  |  | } | 
| 800 |  |  |  |  |  |  |  | 
| 801 |  |  |  |  |  |  | 1; | 
| 802 |  |  |  |  |  |  |  | 
| 803 |  |  |  |  |  |  | # ABSTRACT: The Moose metaclass | 
| 804 |  |  |  |  |  |  |  | 
| 805 |  |  |  |  |  |  | __END__ | 
| 806 |  |  |  |  |  |  |  | 
| 807 |  |  |  |  |  |  | =pod | 
| 808 |  |  |  |  |  |  |  | 
| 809 |  |  |  |  |  |  | =encoding UTF-8 | 
| 810 |  |  |  |  |  |  |  | 
| 811 |  |  |  |  |  |  | =head1 NAME | 
| 812 |  |  |  |  |  |  |  | 
| 813 |  |  |  |  |  |  | Moose::Meta::Class - The Moose metaclass | 
| 814 |  |  |  |  |  |  |  | 
| 815 |  |  |  |  |  |  | =head1 VERSION | 
| 816 |  |  |  |  |  |  |  | 
| 817 |  |  |  |  |  |  | version 2.2203 | 
| 818 |  |  |  |  |  |  |  | 
| 819 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 820 |  |  |  |  |  |  |  | 
| 821 |  |  |  |  |  |  | This class is a subclass of L<Class::MOP::Class> that provides | 
| 822 |  |  |  |  |  |  | additional Moose-specific functionality. | 
| 823 |  |  |  |  |  |  |  | 
| 824 |  |  |  |  |  |  | To really understand this class, you will need to start with the | 
| 825 |  |  |  |  |  |  | L<Class::MOP::Class> documentation. This class can be understood as a | 
| 826 |  |  |  |  |  |  | set of additional features on top of the basic feature provided by | 
| 827 |  |  |  |  |  |  | that parent class. | 
| 828 |  |  |  |  |  |  |  | 
| 829 |  |  |  |  |  |  | =head1 INHERITANCE | 
| 830 |  |  |  |  |  |  |  | 
| 831 |  |  |  |  |  |  | C<Moose::Meta::Class> is a subclass of L<Class::MOP::Class>. | 
| 832 |  |  |  |  |  |  |  | 
| 833 |  |  |  |  |  |  | =head1 METHODS | 
| 834 |  |  |  |  |  |  |  | 
| 835 |  |  |  |  |  |  | =over 4 | 
| 836 |  |  |  |  |  |  |  | 
| 837 |  |  |  |  |  |  | =item B<< Moose::Meta::Class->initialize($package_name, %options) >> | 
| 838 |  |  |  |  |  |  |  | 
| 839 |  |  |  |  |  |  | This overrides the parent's method in order to provide its own | 
| 840 |  |  |  |  |  |  | defaults for the C<attribute_metaclass>, C<instance_metaclass>, and | 
| 841 |  |  |  |  |  |  | C<method_metaclass> options. | 
| 842 |  |  |  |  |  |  |  | 
| 843 |  |  |  |  |  |  | These all default to the appropriate Moose class. | 
| 844 |  |  |  |  |  |  |  | 
| 845 |  |  |  |  |  |  | =item B<< Moose::Meta::Class->create($package_name, %options) >> | 
| 846 |  |  |  |  |  |  |  | 
| 847 |  |  |  |  |  |  | This overrides the parent's method in order to accept a C<roles> | 
| 848 |  |  |  |  |  |  | option. This should be an array reference containing roles | 
| 849 |  |  |  |  |  |  | that the class does, each optionally followed by a hashref of options | 
| 850 |  |  |  |  |  |  | (C<-excludes> and C<-alias>). | 
| 851 |  |  |  |  |  |  |  | 
| 852 |  |  |  |  |  |  | my $metaclass = Moose::Meta::Class->create( 'New::Class', roles => [...] ); | 
| 853 |  |  |  |  |  |  |  | 
| 854 |  |  |  |  |  |  | =item B<< Moose::Meta::Class->create_anon_class >> | 
| 855 |  |  |  |  |  |  |  | 
| 856 |  |  |  |  |  |  | This overrides the parent's method to accept a C<roles> option, just | 
| 857 |  |  |  |  |  |  | as C<create> does. | 
| 858 |  |  |  |  |  |  |  | 
| 859 |  |  |  |  |  |  | It also accepts a C<cache> option. If this is C<true>, then the anonymous | 
| 860 |  |  |  |  |  |  | class will be cached based on its superclasses and roles. If an | 
| 861 |  |  |  |  |  |  | existing anonymous class in the cache has the same superclasses and | 
| 862 |  |  |  |  |  |  | roles, it will be reused. | 
| 863 |  |  |  |  |  |  |  | 
| 864 |  |  |  |  |  |  | my $metaclass = Moose::Meta::Class->create_anon_class( | 
| 865 |  |  |  |  |  |  | superclasses => ['Foo'], | 
| 866 |  |  |  |  |  |  | roles        => [qw/Some Roles Go Here/], | 
| 867 |  |  |  |  |  |  | cache        => 1, | 
| 868 |  |  |  |  |  |  | ); | 
| 869 |  |  |  |  |  |  |  | 
| 870 |  |  |  |  |  |  | Each entry in both the C<superclasses> and the C<roles> option can be | 
| 871 |  |  |  |  |  |  | followed by a hash reference with arguments. The C<superclasses> | 
| 872 |  |  |  |  |  |  | option can be supplied with a L<-version|Class::MOP/Class Loading | 
| 873 |  |  |  |  |  |  | Options> option that ensures the loaded superclass satisfies the | 
| 874 |  |  |  |  |  |  | required version. The C<role> option also takes the C<-version> as an | 
| 875 |  |  |  |  |  |  | argument, but the option hash reference can also contain any other | 
| 876 |  |  |  |  |  |  | role relevant values like exclusions or parameterized role arguments. | 
| 877 |  |  |  |  |  |  |  | 
| 878 |  |  |  |  |  |  | =item B<< $metaclass->new_object(%params) >> | 
| 879 |  |  |  |  |  |  |  | 
| 880 |  |  |  |  |  |  | This overrides the parent's method in order to add support for | 
| 881 |  |  |  |  |  |  | attribute triggers. | 
| 882 |  |  |  |  |  |  |  | 
| 883 |  |  |  |  |  |  | =item B<< $metaclass->superclasses(@superclasses) >> | 
| 884 |  |  |  |  |  |  |  | 
| 885 |  |  |  |  |  |  | This is the accessor allowing you to read or change the parents of | 
| 886 |  |  |  |  |  |  | the class. | 
| 887 |  |  |  |  |  |  |  | 
| 888 |  |  |  |  |  |  | Each superclass can be followed by a hash reference containing a | 
| 889 |  |  |  |  |  |  | L<-version|Class::MOP/Class Loading Options> value. If the version | 
| 890 |  |  |  |  |  |  | requirement is not satisfied an error will be thrown. | 
| 891 |  |  |  |  |  |  |  | 
| 892 |  |  |  |  |  |  | When you pass classes to this method, we will attempt to load them if they are | 
| 893 |  |  |  |  |  |  | not already loaded. | 
| 894 |  |  |  |  |  |  |  | 
| 895 |  |  |  |  |  |  | =item B<< $metaclass->add_override_method_modifier($name, $sub) >> | 
| 896 |  |  |  |  |  |  |  | 
| 897 |  |  |  |  |  |  | This adds an C<override> method modifier to the package. | 
| 898 |  |  |  |  |  |  |  | 
| 899 |  |  |  |  |  |  | =item B<< $metaclass->add_augment_method_modifier($name, $sub) >> | 
| 900 |  |  |  |  |  |  |  | 
| 901 |  |  |  |  |  |  | This adds an C<augment> method modifier to the package. | 
| 902 |  |  |  |  |  |  |  | 
| 903 |  |  |  |  |  |  | =item B<< $metaclass->calculate_all_roles >> | 
| 904 |  |  |  |  |  |  |  | 
| 905 |  |  |  |  |  |  | This will return a unique array of L<Moose::Meta::Role> instances | 
| 906 |  |  |  |  |  |  | which are attached to this class. | 
| 907 |  |  |  |  |  |  |  | 
| 908 |  |  |  |  |  |  | =item B<< $metaclass->calculate_all_roles_with_inheritance >> | 
| 909 |  |  |  |  |  |  |  | 
| 910 |  |  |  |  |  |  | This will return a unique array of L<Moose::Meta::Role> instances | 
| 911 |  |  |  |  |  |  | which are attached to this class, and each of this class's ancestors. | 
| 912 |  |  |  |  |  |  |  | 
| 913 |  |  |  |  |  |  | =item B<< $metaclass->add_role($role) >> | 
| 914 |  |  |  |  |  |  |  | 
| 915 |  |  |  |  |  |  | This takes a L<Moose::Meta::Role> object, and adds it to the class's | 
| 916 |  |  |  |  |  |  | list of roles. This I<does not> actually apply the role to the class. | 
| 917 |  |  |  |  |  |  |  | 
| 918 |  |  |  |  |  |  | =item B<< $metaclass->role_applications >> | 
| 919 |  |  |  |  |  |  |  | 
| 920 |  |  |  |  |  |  | Returns a list of L<Moose::Meta::Role::Application::ToClass> | 
| 921 |  |  |  |  |  |  | objects, which contain the arguments to role application. | 
| 922 |  |  |  |  |  |  |  | 
| 923 |  |  |  |  |  |  | =item B<< $metaclass->add_role_application($application) >> | 
| 924 |  |  |  |  |  |  |  | 
| 925 |  |  |  |  |  |  | This takes a L<Moose::Meta::Role::Application::ToClass> object, and | 
| 926 |  |  |  |  |  |  | adds it to the class's list of role applications. This I<does not> | 
| 927 |  |  |  |  |  |  | actually apply any role to the class; it is only for tracking role | 
| 928 |  |  |  |  |  |  | applications. | 
| 929 |  |  |  |  |  |  |  | 
| 930 |  |  |  |  |  |  | =item B<< $metaclass->does_role($role) >> | 
| 931 |  |  |  |  |  |  |  | 
| 932 |  |  |  |  |  |  | This returns a boolean indicating whether or not the class does the specified | 
| 933 |  |  |  |  |  |  | role. The role provided can be either a role name or a L<Moose::Meta::Role> | 
| 934 |  |  |  |  |  |  | object. This tests both the class and its parents. | 
| 935 |  |  |  |  |  |  |  | 
| 936 |  |  |  |  |  |  | =item B<< $metaclass->excludes_role($role_name) >> | 
| 937 |  |  |  |  |  |  |  | 
| 938 |  |  |  |  |  |  | A class excludes a role if it has already composed a role which | 
| 939 |  |  |  |  |  |  | excludes the named role. This tests both the class and its parents. | 
| 940 |  |  |  |  |  |  |  | 
| 941 |  |  |  |  |  |  | =item B<< $metaclass->add_attribute($attr_name, %params|$params) >> | 
| 942 |  |  |  |  |  |  |  | 
| 943 |  |  |  |  |  |  | This overrides the parent's method in order to allow the parameters to | 
| 944 |  |  |  |  |  |  | be provided as a hash reference. | 
| 945 |  |  |  |  |  |  |  | 
| 946 |  |  |  |  |  |  | =item B<< $metaclass->constructor_class($class_name) >> | 
| 947 |  |  |  |  |  |  |  | 
| 948 |  |  |  |  |  |  | =item B<< $metaclass->destructor_class($class_name) >> | 
| 949 |  |  |  |  |  |  |  | 
| 950 |  |  |  |  |  |  | These are the names of classes used when making a class immutable. These | 
| 951 |  |  |  |  |  |  | default to L<Moose::Meta::Method::Constructor> and | 
| 952 |  |  |  |  |  |  | L<Moose::Meta::Method::Destructor> respectively. These accessors are | 
| 953 |  |  |  |  |  |  | read-write, so you can use them to change the class name. | 
| 954 |  |  |  |  |  |  |  | 
| 955 |  |  |  |  |  |  | =back | 
| 956 |  |  |  |  |  |  |  | 
| 957 |  |  |  |  |  |  | =head1 BUGS | 
| 958 |  |  |  |  |  |  |  | 
| 959 |  |  |  |  |  |  | See L<Moose/BUGS> for details on reporting bugs. | 
| 960 |  |  |  |  |  |  |  | 
| 961 |  |  |  |  |  |  | =head1 AUTHORS | 
| 962 |  |  |  |  |  |  |  | 
| 963 |  |  |  |  |  |  | =over 4 | 
| 964 |  |  |  |  |  |  |  | 
| 965 |  |  |  |  |  |  | =item * | 
| 966 |  |  |  |  |  |  |  | 
| 967 |  |  |  |  |  |  | Stevan Little <stevan@cpan.org> | 
| 968 |  |  |  |  |  |  |  | 
| 969 |  |  |  |  |  |  | =item * | 
| 970 |  |  |  |  |  |  |  | 
| 971 |  |  |  |  |  |  | Dave Rolsky <autarch@urth.org> | 
| 972 |  |  |  |  |  |  |  | 
| 973 |  |  |  |  |  |  | =item * | 
| 974 |  |  |  |  |  |  |  | 
| 975 |  |  |  |  |  |  | Jesse Luehrs <doy@cpan.org> | 
| 976 |  |  |  |  |  |  |  | 
| 977 |  |  |  |  |  |  | =item * | 
| 978 |  |  |  |  |  |  |  | 
| 979 |  |  |  |  |  |  | Shawn M Moore <sartak@cpan.org> | 
| 980 |  |  |  |  |  |  |  | 
| 981 |  |  |  |  |  |  | =item * | 
| 982 |  |  |  |  |  |  |  | 
| 983 |  |  |  |  |  |  | יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org> | 
| 984 |  |  |  |  |  |  |  | 
| 985 |  |  |  |  |  |  | =item * | 
| 986 |  |  |  |  |  |  |  | 
| 987 |  |  |  |  |  |  | Karen Etheridge <ether@cpan.org> | 
| 988 |  |  |  |  |  |  |  | 
| 989 |  |  |  |  |  |  | =item * | 
| 990 |  |  |  |  |  |  |  | 
| 991 |  |  |  |  |  |  | Florian Ragwitz <rafl@debian.org> | 
| 992 |  |  |  |  |  |  |  | 
| 993 |  |  |  |  |  |  | =item * | 
| 994 |  |  |  |  |  |  |  | 
| 995 |  |  |  |  |  |  | Hans Dieter Pearcey <hdp@cpan.org> | 
| 996 |  |  |  |  |  |  |  | 
| 997 |  |  |  |  |  |  | =item * | 
| 998 |  |  |  |  |  |  |  | 
| 999 |  |  |  |  |  |  | Chris Prather <chris@prather.org> | 
| 1000 |  |  |  |  |  |  |  | 
| 1001 |  |  |  |  |  |  | =item * | 
| 1002 |  |  |  |  |  |  |  | 
| 1003 |  |  |  |  |  |  | Matt S Trout <mstrout@cpan.org> | 
| 1004 |  |  |  |  |  |  |  | 
| 1005 |  |  |  |  |  |  | =back | 
| 1006 |  |  |  |  |  |  |  | 
| 1007 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENSE | 
| 1008 |  |  |  |  |  |  |  | 
| 1009 |  |  |  |  |  |  | This software is copyright (c) 2006 by Infinity Interactive, Inc. | 
| 1010 |  |  |  |  |  |  |  | 
| 1011 |  |  |  |  |  |  | This is free software; you can redistribute it and/or modify it under | 
| 1012 |  |  |  |  |  |  | the same terms as the Perl 5 programming language system itself. | 
| 1013 |  |  |  |  |  |  |  | 
| 1014 |  |  |  |  |  |  | =cut |