| File | /usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/Moose/Meta/Role.pm |
| Statements Executed | 2887 |
| Statement Execution Time | 39.6ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 163 | 2 | 2 | 5.44ms | 7.41ms | Moose::Meta::Role::does_role |
| 180 | 6 | 3 | 5.09ms | 6.72ms | Moose::Meta::Role::get_method_modifier_list |
| 37 | 2 | 1 | 3.10ms | 836ms | Moose::Meta::Role::apply |
| 1 | 1 | 1 | 2.28ms | 8.22ms | Moose::Meta::Role::BEGIN@17 |
| 32 | 3 | 2 | 1.52ms | 34.0ms | Moose::Meta::Role::initialize |
| 25 | 3 | 3 | 1.32ms | 9.20ms | Moose::Meta::Role::add_attribute |
| 102 | 7 | 3 | 1.09ms | 1.09ms | Moose::Meta::Role::__ANON__[:256] |
| 15 | 3 | 3 | 991µs | 3.07ms | Moose::Meta::Role::add_required_methods |
| 3 | 1 | 1 | 873µs | 21.1ms | Moose::Meta::Role::reinitialize |
| 4 | 1 | 1 | 669µs | 81.0ms | Moose::Meta::Role::combine |
| 1 | 1 | 1 | 605µs | 2.34ms | Moose::Meta::Role::BEGIN@19 |
| 11 | 1 | 1 | 604µs | 1.09ms | Moose::Meta::Role::add_role |
| 1 | 1 | 1 | 492µs | 2.20ms | Moose::Meta::Role::BEGIN@20 |
| 68 | 5 | 3 | 469µs | 469µs | Moose::Meta::Role::__ANON__[:83] |
| 25 | 1 | 1 | 438µs | 1.87ms | Moose::Meta::Role::_attach_attribute |
| 1 | 1 | 1 | 338µs | 566µs | Moose::Meta::Role::BEGIN@18 |
| 30 | 2 | 2 | 285µs | 285µs | Moose::Meta::Role::__ANON__[:352] |
| 34 | 3 | 3 | 238µs | 238µs | Moose::Meta::Role::__ANON__[:301] |
| 12 | 1 | 1 | 224µs | 3.99ms | Moose::Meta::Role::find_method_by_name |
| 3 | 2 | 2 | 144µs | 245µs | Moose::Meta::Role::DESTROY |
| 1 | 1 | 1 | 140µs | 467µs | Moose::Meta::Role::BEGIN@8 |
| 11 | 1 | 1 | 124µs | 124µs | Moose::Meta::Role::reset_package_cache_flag |
| 1 | 1 | 1 | 119µs | 119µs | Moose::Meta::Role::BEGIN@16 |
| 1 | 1 | 1 | 89µs | 198µs | Moose::Meta::Role::BEGIN@9 |
| 8 | 1 | 1 | 62µs | 62µs | Moose::Meta::Role::_role_for_combination |
| 1 | 1 | 1 | 59µs | 74µs | Moose::Meta::Role::BEGIN@4 |
| 2 | 1 | 1 | 59µs | 504µs | Moose::Meta::Role::add_override_method_modifier |
| 3 | 1 | 2 | 47µs | 47µs | Moose::Meta::Role::CORE:regcomp (opcode) |
| 8 | 1 | 1 | 40µs | 40µs | Moose::Meta::Role::composition_class_roles |
| 2 | 1 | 1 | 33µs | 48µs | Moose::Meta::Role::get_override_method_modifier |
| 1 | 1 | 1 | 31µs | 88µs | Moose::Meta::Role::BEGIN@5 |
| 1 | 1 | 1 | 31µs | 785µs | Moose::Meta::Role::BEGIN@10 |
| 1 | 1 | 1 | 29µs | 1.62ms | Moose::Meta::Role::BEGIN@6 |
| 1 | 1 | 1 | 27µs | 98µs | Moose::Meta::Role::BEGIN@523 |
| 1 | 1 | 1 | 21µs | 48µs | Moose::Meta::Role::BEGIN@544 |
| 1 | 1 | 1 | 21µs | 476µs | Moose::Meta::Role::BEGIN@21 |
| 1 | 1 | 1 | 20µs | 52µs | Moose::Meta::Role::BEGIN@559 |
| 1 | 1 | 1 | 19µs | 260µs | Moose::Meta::Role::BEGIN@23 |
| 3 | 1 | 2 | 6µs | 6µs | Moose::Meta::Role::CORE:match (opcode) |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::__ANON__[:100] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::__ANON__[:105] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::__ANON__[:110] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::__ANON__[:115] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::__ANON__[:265] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::__ANON__[:273] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::__ANON__[:292] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::__ANON__[:482] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::__ANON__[:90] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::__ANON__[:95] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::add_conflicting_method |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::alias_method |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::calculate_all_roles |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::create |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::create_anon_role |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::has_override_method_modifier |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::is_anon_role |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::update_package_cache_flag |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | package Moose::Meta::Role; | ||||
| 3 | |||||
| 4 | 3 | 90µs | 2 | 89µs | # spent 74µs (59+15) within Moose::Meta::Role::BEGIN@4 which was called
# once (59µs+15µs) by Moose::BEGIN@26 at line 4 # spent 74µs making 1 call to Moose::Meta::Role::BEGIN@4
# spent 15µs making 1 call to strict::import |
| 5 | 3 | 82µs | 2 | 144µs | # spent 88µs (31+57) within Moose::Meta::Role::BEGIN@5 which was called
# once (31µs+57µs) by Moose::BEGIN@26 at line 5 # spent 88µs making 1 call to Moose::Meta::Role::BEGIN@5
# spent 56µs making 1 call to warnings::import |
| 6 | 3 | 150µs | 2 | 3.21ms | # spent 1.62ms (29µs+1.59) within Moose::Meta::Role::BEGIN@6 which was called
# once (29µs+1.59ms) by Moose::BEGIN@26 at line 6 # spent 1.62ms making 1 call to Moose::Meta::Role::BEGIN@6
# spent 1.59ms making 1 call to metaclass::import |
| 7 | |||||
| 8 | 3 | 272µs | 2 | 794µs | # spent 467µs (140+327) within Moose::Meta::Role::BEGIN@8 which was called
# once (140µs+327µs) by Moose::BEGIN@26 at line 8 # spent 467µs making 1 call to Moose::Meta::Role::BEGIN@8
# spent 327µs making 1 call to Exporter::import |
| 9 | 3 | 130µs | 2 | 306µs | # spent 198µs (89+109) within Moose::Meta::Role::BEGIN@9 which was called
# once (89µs+109µs) by Moose::BEGIN@26 at line 9 # spent 198µs making 1 call to Moose::Meta::Role::BEGIN@9
# spent 109µs making 1 call to Exporter::import |
| 10 | 3 | 261µs | 2 | 1.54ms | # spent 785µs (31+754) within Moose::Meta::Role::BEGIN@10 which was called
# once (31µs+754µs) by Moose::BEGIN@26 at line 10 # spent 785µs making 1 call to Moose::Meta::Role::BEGIN@10
# spent 754µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756] |
| 11 | |||||
| 12 | 1 | 2µs | our $VERSION = '1.01'; | ||
| 13 | 1 | 33µs | $VERSION = eval $VERSION; | ||
| 14 | 1 | 2µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 15 | |||||
| 16 | 3 | 142µs | 1 | 119µs | # spent 119µs within Moose::Meta::Role::BEGIN@16 which was called
# once (119µs+0s) by Moose::BEGIN@26 at line 16 # spent 119µs making 1 call to Moose::Meta::Role::BEGIN@16 |
| 17 | 3 | 347µs | 1 | 8.22ms | # spent 8.22ms (2.28+5.93) within Moose::Meta::Role::BEGIN@17 which was called
# once (2.28ms+5.93ms) by Moose::BEGIN@26 at line 17 # spent 8.22ms making 1 call to Moose::Meta::Role::BEGIN@17 |
| 18 | 3 | 187µs | 1 | 566µs | # spent 566µs (338+229) within Moose::Meta::Role::BEGIN@18 which was called
# once (338µs+229µs) by Moose::BEGIN@26 at line 18 # spent 566µs making 1 call to Moose::Meta::Role::BEGIN@18 |
| 19 | 3 | 158µs | 1 | 2.34ms | # spent 2.34ms (605µs+1.73) within Moose::Meta::Role::BEGIN@19 which was called
# once (605µs+1.73ms) by Moose::BEGIN@26 at line 19 # spent 2.34ms making 1 call to Moose::Meta::Role::BEGIN@19 |
| 20 | 3 | 223µs | 1 | 2.20ms | # spent 2.20ms (492µs+1.71) within Moose::Meta::Role::BEGIN@20 which was called
# once (492µs+1.71ms) by Moose::BEGIN@26 at line 20 # spent 2.20ms making 1 call to Moose::Meta::Role::BEGIN@20 |
| 21 | 3 | 66µs | 2 | 931µs | # spent 476µs (21+455) within Moose::Meta::Role::BEGIN@21 which was called
# once (21µs+455µs) by Moose::BEGIN@26 at line 21 # spent 476µs making 1 call to Moose::Meta::Role::BEGIN@21
# spent 455µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756] |
| 22 | |||||
| 23 | 3 | 4.43ms | 2 | 500µs | # spent 260µs (19+241) within Moose::Meta::Role::BEGIN@23 which was called
# once (19µs+241µs) by Moose::BEGIN@26 at line 23 # spent 260µs making 1 call to Moose::Meta::Role::BEGIN@23
# spent 241µs making 1 call to base::import |
| 24 | |||||
| 25 | ## ------------------------------------------------------------------ | ||||
| 26 | ## NOTE: | ||||
| 27 | ## I normally don't do this, but I am doing | ||||
| 28 | ## a whole bunch of meta-programmin in this | ||||
| 29 | ## module, so it just makes sense. For a clearer | ||||
| 30 | ## picture of what is going on in the next | ||||
| 31 | ## several lines of code, look at the really | ||||
| 32 | ## big comment at the end of this file (right | ||||
| 33 | ## before the POD). | ||||
| 34 | ## - SL | ||||
| 35 | ## ------------------------------------------------------------------ | ||||
| 36 | |||||
| 37 | 1 | 6µs | 1 | 48µs | my $META = __PACKAGE__->meta; # spent 48µs making 1 call to Moose::Meta::Role::meta |
| 38 | |||||
| 39 | ## ------------------------------------------------------------------ | ||||
| 40 | ## attributes ... | ||||
| 41 | |||||
| 42 | # NOTE: | ||||
| 43 | # since roles are lazy, we hold all the attributes | ||||
| 44 | # of the individual role in 'statis' until which | ||||
| 45 | # time when it is applied to a class. This means | ||||
| 46 | # keeping a lot of things in hash maps, so we are | ||||
| 47 | # using a little of that meta-programmin' magic | ||||
| 48 | # here an saving lots of extra typin. And since | ||||
| 49 | # many of these attributes above require similar | ||||
| 50 | # functionality to support them, so we again use | ||||
| 51 | # the wonders of meta-programmin' to deliver a | ||||
| 52 | # very compact solution to this normally verbose | ||||
| 53 | # problem. | ||||
| 54 | # - SL | ||||
| 55 | |||||
| 56 | 1 | 21µs | foreach my $action ( | ||
| 57 | { | ||||
| 58 | name => 'excluded_roles_map', | ||||
| 59 | attr_reader => 'get_excluded_roles_map' , | ||||
| 60 | methods => { | ||||
| 61 | add => 'add_excluded_roles', | ||||
| 62 | get_keys => 'get_excluded_roles_list', | ||||
| 63 | existence => 'excludes_role', | ||||
| 64 | } | ||||
| 65 | }, | ||||
| 66 | { | ||||
| 67 | name => 'required_methods', | ||||
| 68 | attr_reader => 'get_required_methods_map', | ||||
| 69 | methods => { | ||||
| 70 | remove => 'remove_required_methods', | ||||
| 71 | get_values => 'get_required_method_list', | ||||
| 72 | existence => 'requires_method', | ||||
| 73 | } | ||||
| 74 | }, | ||||
| 75 | ) { | ||||
| 76 | |||||
| 77 | 2 | 4µs | my $attr_reader = $action->{attr_reader}; | ||
| 78 | 2 | 7µs | my $methods = $action->{methods}; | ||
| 79 | |||||
| 80 | # create the attribute | ||||
| 81 | $META->add_attribute($action->{name} => ( | ||||
| 82 | reader => $attr_reader, | ||||
| 83 | 68 | 859µs | # spent 469µs within Moose::Meta::Role::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/Moose/Meta/Role.pm:83] which was called 68 times, avg 7µs/call:
# 27 times (215µs+0s) by Moose::Meta::Role::_new at line 11 of (eval 0)[Class/MOP/Method/Generated.pm:54] at line 54 of Class/MOP/Method/Generated.pm, avg 8µs/call
# 27 times (157µs+0s) by Moose::Meta::Role::_new at line 88 of (eval 0)[Class/MOP/Method/Generated.pm:54] at line 54 of Class/MOP/Method/Generated.pm, avg 6µs/call
# 6 times (45µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm, avg 8µs/call
# 4 times (30µs+0s) by Moose::Meta::Role::Composite::_new at line 11 of (eval 0)[Class/MOP/Method/Generated.pm:54] at line 54 of Class/MOP/Method/Generated.pm, avg 8µs/call
# 4 times (22µs+0s) by Moose::Meta::Role::Composite::_new at line 96 of (eval 0)[Class/MOP/Method/Generated.pm:54] at line 54 of Class/MOP/Method/Generated.pm, avg 5µs/call | ||
| 84 | 2 | 21µs | 2 | 2.61ms | )); # spent 2.61ms making 2 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 1.31ms/call |
| 85 | |||||
| 86 | # create some helper methods | ||||
| 87 | $META->add_method($methods->{add} => sub { | ||||
| 88 | 12 | 94µs | my ($self, @values) = @_; | ||
| 89 | $self->$attr_reader->{$_} = undef foreach @values; | ||||
| 90 | 2 | 15µs | 1 | 91µs | }) if exists $methods->{add}; # spent 91µs making 1 call to Class::MOP::Mixin::HasMethods::add_method |
| 91 | |||||
| 92 | $META->add_method($methods->{get_keys} => sub { | ||||
| 93 | 90 | 839µs | my ($self) = @_; | ||
| 94 | keys %{$self->$attr_reader}; # spent 403µs making 45 calls to Moose::Meta::Role::get_excluded_roles_map, avg 9µs/call | ||||
| 95 | 2 | 12µs | 1 | 128µs | }) if exists $methods->{get_keys}; # spent 128µs making 1 call to Class::MOP::Mixin::HasMethods::add_method |
| 96 | |||||
| 97 | $META->add_method($methods->{get_values} => sub { | ||||
| 98 | 90 | 954µs | my ($self) = @_; | ||
| 99 | values %{$self->$attr_reader}; # spent 395µs making 45 calls to Moose::Meta::Role::get_required_methods_map, avg 9µs/call | ||||
| 100 | 2 | 22µs | 1 | 172µs | }) if exists $methods->{get_values}; # spent 172µs making 1 call to Class::MOP::Mixin::HasMethods::add_method |
| 101 | |||||
| 102 | $META->add_method($methods->{get} => sub { | ||||
| 103 | my ($self, $name) = @_; | ||||
| 104 | $self->$attr_reader->{$name} | ||||
| 105 | 2 | 3µs | }) if exists $methods->{get}; | ||
| 106 | |||||
| 107 | $META->add_method($methods->{existence} => sub { | ||||
| 108 | 44 | 384µs | my ($self, $name) = @_; | ||
| 109 | exists $self->$attr_reader->{$name} ? 1 : 0; # spent 173µs making 22 calls to Moose::Meta::Role::get_excluded_roles_map, avg 8µs/call | ||||
| 110 | 2 | 149µs | 2 | 316µs | }) if exists $methods->{existence}; # spent 316µs making 2 calls to Class::MOP::Mixin::HasMethods::add_method, avg 158µs/call |
| 111 | |||||
| 112 | $META->add_method($methods->{remove} => sub { | ||||
| 113 | my ($self, @values) = @_; | ||||
| 114 | delete $self->$attr_reader->{$_} foreach @values; | ||||
| 115 | 2 | 28µs | 1 | 269µs | }) if exists $methods->{remove}; # spent 269µs making 1 call to Class::MOP::Mixin::HasMethods::add_method |
| 116 | } | ||||
| 117 | |||||
| 118 | $META->add_attribute( | ||||
| 119 | 1 | 8µs | 1 | 1.57ms | 'method_metaclass', # spent 1.57ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute |
| 120 | reader => 'method_metaclass', | ||||
| 121 | default => 'Moose::Meta::Role::Method', | ||||
| 122 | ); | ||||
| 123 | |||||
| 124 | 1 | 8µs | 1 | 2.20ms | $META->add_attribute( # spent 2.20ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute |
| 125 | 'required_method_metaclass', | ||||
| 126 | reader => 'required_method_metaclass', | ||||
| 127 | default => 'Moose::Meta::Role::Method::Required', | ||||
| 128 | ); | ||||
| 129 | |||||
| 130 | 1 | 8µs | 1 | 3.05ms | $META->add_attribute( # spent 3.05ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute |
| 131 | 'conflicting_method_metaclass', | ||||
| 132 | reader => 'conflicting_method_metaclass', | ||||
| 133 | default => 'Moose::Meta::Role::Method::Conflicting', | ||||
| 134 | ); | ||||
| 135 | |||||
| 136 | 1 | 8µs | 1 | 1.76ms | $META->add_attribute( # spent 1.76ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute |
| 137 | 'application_to_class_class', | ||||
| 138 | reader => 'application_to_class_class', | ||||
| 139 | default => 'Moose::Meta::Role::Application::ToClass', | ||||
| 140 | ); | ||||
| 141 | |||||
| 142 | 1 | 8µs | 1 | 1.58ms | $META->add_attribute( # spent 1.58ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute |
| 143 | 'application_to_role_class', | ||||
| 144 | reader => 'application_to_role_class', | ||||
| 145 | default => 'Moose::Meta::Role::Application::ToRole', | ||||
| 146 | ); | ||||
| 147 | |||||
| 148 | 1 | 8µs | 1 | 1.75ms | $META->add_attribute( # spent 1.75ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute |
| 149 | 'application_to_instance_class', | ||||
| 150 | reader => 'application_to_instance_class', | ||||
| 151 | default => 'Moose::Meta::Role::Application::ToInstance', | ||||
| 152 | ); | ||||
| 153 | |||||
| 154 | # More or less copied from Moose::Meta::Class | ||||
| 155 | # spent 34.0ms (1.52+32.5) within Moose::Meta::Role::initialize which was called 32 times, avg 1.06ms/call:
# 27 times (1.36ms+13.4ms) by Moose::Role::init_meta at line 129 of Moose/Role.pm, avg 545µs/call
# 3 times (133µs+19.1ms) by Class::MOP::Package::reinitialize at line 59 of Class/MOP/Package.pm, avg 6.41ms/call
# 2 times (25µs+9µs) by Catalyst::Exception::Basic::meta or Catalyst::Exception::Interface::meta at line 134 of Moose/Role.pm, avg 17µs/call | ||||
| 156 | 96 | 1.37ms | my $class = shift; | ||
| 157 | my $pkg = shift; | ||||
| 158 | return Class::MOP::get_metaclass_by_name($pkg) # spent 32.2ms making 30 calls to Class::MOP::Package::initialize, avg 1.07ms/call
# spent 213µs making 32 calls to Class::MOP::get_metaclass_by_name, avg 7µs/call | ||||
| 159 | || $class->SUPER::initialize( | ||||
| 160 | $pkg, | ||||
| 161 | 'attribute_metaclass' => 'Moose::Meta::Role::Attribute', | ||||
| 162 | @_ | ||||
| 163 | ); | ||||
| 164 | } | ||||
| 165 | |||||
| 166 | # spent 21.1ms (873µs+20.3) within Moose::Meta::Role::reinitialize which was called 3 times, avg 7.05ms/call:
# 3 times (873µs+20.3ms) by Moose::Util::MetaRole::_make_new_metaclass at line 115 of Moose/Util/MetaRole.pm, avg 7.05ms/call | ||||
| 167 | 18 | 653µs | my $self = shift; | ||
| 168 | my $pkg = shift; | ||||
| 169 | |||||
| 170 | my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg); # spent 16µs making 3 calls to Scalar::Util::blessed, avg 5µs/call | ||||
| 171 | |||||
| 172 | my %existing_classes; | ||||
| 173 | if ($meta) { # spent 125µs making 3 calls to Moose::Meta::Role::conflicting_method_metaclass, avg 42µs/call
# spent 74µs making 3 calls to Moose::Meta::Role::application_to_instance_class, avg 25µs/call
# spent 39µs making 3 calls to Moose::Meta::Role::application_to_role_class, avg 13µs/call
# spent 30µs making 3 calls to Moose::Meta::Role::method_metaclass, avg 10µs/call
# spent 29µs making 3 calls to Moose::Meta::Role::required_method_metaclass, avg 10µs/call
# spent 28µs making 3 calls to Moose::Meta::Role::application_to_class_class, avg 10µs/call
# spent 28µs making 3 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 9µs/call
# spent 27µs making 3 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 9µs/call | ||||
| 174 | %existing_classes = map { $_ => $meta->$_() } qw( | ||||
| 175 | attribute_metaclass | ||||
| 176 | method_metaclass | ||||
| 177 | wrapped_method_metaclass | ||||
| 178 | required_method_metaclass | ||||
| 179 | conflicting_method_metaclass | ||||
| 180 | application_to_class_class | ||||
| 181 | application_to_role_class | ||||
| 182 | application_to_instance_class | ||||
| 183 | ); | ||||
| 184 | } | ||||
| 185 | |||||
| 186 | return $self->SUPER::reinitialize( # spent 19.9ms making 3 calls to Class::MOP::Package::reinitialize, avg 6.62ms/call | ||||
| 187 | $pkg, | ||||
| 188 | %existing_classes, | ||||
| 189 | @_, | ||||
| 190 | ); | ||||
| 191 | } | ||||
| 192 | |||||
| 193 | # spent 9.20ms (1.32+7.88) within Moose::Meta::Role::add_attribute which was called 25 times, avg 368µs/call:
# 11 times (690µs+2.76ms) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 65 of Moose/Meta/Role/Application/ToRole.pm, avg 314µs/call
# 8 times (267µs+3.34ms) by Moose::Role::has at line 47 of Moose/Role.pm, avg 451µs/call
# 6 times (359µs+1.78ms) by Moose::Meta::Role::Application::RoleSummation::apply_attributes at line 148 of Moose/Meta/Role/Application/RoleSummation.pm, avg 356µs/call | ||||
| 194 | 75 | 1.38ms | my $self = shift; | ||
| 195 | |||||
| 196 | if (blessed $_[0] && ! $_[0]->isa('Moose::Meta::Role::Attribute') ) { # spent 107µs making 25 calls to Scalar::Util::blessed, avg 4µs/call
# spent 68µs making 17 calls to UNIVERSAL::isa, avg 4µs/call | ||||
| 197 | my $class = ref $_[0]; | ||||
| 198 | Moose->throw_error( "Cannot add a $class as an attribute to a role" ); | ||||
| 199 | } | ||||
| 200 | |||||
| 201 | return $self->SUPER::add_attribute(@_); # spent 7.71ms making 25 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 308µs/call | ||||
| 202 | } | ||||
| 203 | |||||
| 204 | # spent 1.87ms (438µs+1.43) within Moose::Meta::Role::_attach_attribute which was called 25 times, avg 75µs/call:
# 25 times (438µs+1.43ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 28 of Class/MOP/Mixin/HasAttributes.pm, avg 75µs/call | ||||
| 205 | 50 | 386µs | my ( $self, $attribute ) = @_; | ||
| 206 | |||||
| 207 | $attribute->attach_to_role($self); # spent 1.43ms making 25 calls to Moose::Meta::Role::Attribute::attach_to_role, avg 57µs/call | ||||
| 208 | } | ||||
| 209 | |||||
| 210 | # spent 3.07ms (991µs+2.08) within Moose::Meta::Role::add_required_methods which was called 15 times, avg 204µs/call:
# 8 times (317µs+272µs) by Moose::Meta::Role::Application::ToRole::check_required_methods at line 43 of Moose/Meta/Role/Application/ToRole.pm, avg 74µs/call
# 4 times (238µs+114µs) by Moose::Meta::Role::Application::RoleSummation::check_required_methods at line 109 of Moose/Meta/Role/Application/RoleSummation.pm, avg 88µs/call
# 3 times (436µs+1.69ms) by Moose::Role::requires at line 32 of Moose/Role.pm, avg 708µs/call | ||||
| 211 | 87 | 1.19ms | my $self = shift; | ||
| 212 | |||||
| 213 | for (@_) { | ||||
| 214 | my $method = $_; | ||||
| 215 | if (!blessed($method)) { # spent 1.37ms making 6 calls to Moose::Meta::Role::Method::Required::new, avg 229µs/call
# spent 317µs making 19 calls to Scalar::Util::blessed, avg 17µs/call
# spent 63µs making 6 calls to Moose::Meta::Role::required_method_metaclass, avg 10µs/call | ||||
| 216 | $method = $self->required_method_metaclass->new( | ||||
| 217 | name => $method, | ||||
| 218 | ); | ||||
| 219 | } | ||||
| 220 | $self->get_required_methods_map->{$method->name} = $method; # spent 167µs making 19 calls to Moose::Meta::Role::get_required_methods_map, avg 9µs/call
# spent 154µs making 19 calls to Moose::Meta::Role::Method::Required::name, avg 8µs/call | ||||
| 221 | } | ||||
| 222 | } | ||||
| 223 | |||||
| 224 | sub add_conflicting_method { | ||||
| 225 | my $self = shift; | ||||
| 226 | |||||
| 227 | my $method; | ||||
| 228 | if (@_ == 1 && blessed($_[0])) { | ||||
| 229 | $method = shift; | ||||
| 230 | } | ||||
| 231 | else { | ||||
| 232 | $method = $self->conflicting_method_metaclass->new(@_); | ||||
| 233 | } | ||||
| 234 | |||||
| 235 | $self->add_required_methods($method); | ||||
| 236 | } | ||||
| 237 | |||||
| 238 | ## ------------------------------------------------------------------ | ||||
| 239 | ## method modifiers | ||||
| 240 | |||||
| 241 | # NOTE: | ||||
| 242 | # the before/around/after method modifiers are | ||||
| 243 | # stored by name, but there can be many methods | ||||
| 244 | # then associated with that name. So again we have | ||||
| 245 | # lots of similar functionality, so we can do some | ||||
| 246 | # meta-programmin' and save some time. | ||||
| 247 | # - SL | ||||
| 248 | |||||
| 249 | 1 | 5µs | foreach my $modifier_type (qw[ before around after ]) { | ||
| 250 | |||||
| 251 | 3 | 198µs | my $attr_reader = "get_${modifier_type}_method_modifiers_map"; | ||
| 252 | |||||
| 253 | # create the attribute ... | ||||
| 254 | $META->add_attribute("${modifier_type}_method_modifiers" => ( | ||||
| 255 | reader => $attr_reader, | ||||
| 256 | 102 | 1.22ms | # spent 1.09ms within Moose::Meta::Role::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/Moose/Meta/Role.pm:256] which was called 102 times, avg 11µs/call:
# 27 times (468µs+0s) by Moose::Meta::Role::_new at line 31 of (eval 0)[Class/MOP/Method/Generated.pm:54] at line 54 of Class/MOP/Method/Generated.pm, avg 17µs/call
# 27 times (162µs+0s) by Moose::Meta::Role::_new at line 60 of (eval 0)[Class/MOP/Method/Generated.pm:54] at line 54 of Class/MOP/Method/Generated.pm, avg 6µs/call
# 27 times (154µs+0s) by Moose::Meta::Role::_new at line 55 of (eval 0)[Class/MOP/Method/Generated.pm:54] at line 54 of Class/MOP/Method/Generated.pm, avg 6µs/call
# 9 times (62µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm, avg 7µs/call
# 4 times (190µs+0s) by Moose::Meta::Role::Composite::_new at line 68 of (eval 0)[Class/MOP/Method/Generated.pm:54] at line 54 of Class/MOP/Method/Generated.pm, avg 48µs/call
# 4 times (26µs+0s) by Moose::Meta::Role::Composite::_new at line 36 of (eval 0)[Class/MOP/Method/Generated.pm:54] at line 54 of Class/MOP/Method/Generated.pm, avg 7µs/call
# 4 times (23µs+0s) by Moose::Meta::Role::Composite::_new at line 63 of (eval 0)[Class/MOP/Method/Generated.pm:54] at line 54 of Class/MOP/Method/Generated.pm, avg 6µs/call | ||
| 257 | 3 | 45µs | 3 | 8.32ms | )); # spent 8.32ms making 3 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 2.77ms/call |
| 258 | |||||
| 259 | # and some helper methods ... | ||||
| 260 | $META->add_method("get_${modifier_type}_method_modifiers" => sub { | ||||
| 261 | 141 | 1.22ms | my ($self, $method_name) = @_; | ||
| 262 | #return () unless exists $self->$attr_reader->{$method_name}; | ||||
| 263 | my $mm = $self->$attr_reader->{$method_name}; # spent 256µs making 29 calls to Moose::Meta::Role::get_around_method_modifiers_map, avg 9µs/call
# spent 98µs making 14 calls to Moose::Meta::Role::get_after_method_modifiers_map, avg 7µs/call
# spent 36µs making 4 calls to Moose::Meta::Role::get_before_method_modifiers_map, avg 9µs/call | ||||
| 264 | $mm ? @$mm : (); | ||||
| 265 | 3 | 67µs | 3 | 587µs | }); # spent 587µs making 3 calls to Class::MOP::Mixin::HasMethods::add_method, avg 196µs/call |
| 266 | |||||
| 267 | $META->add_method("has_${modifier_type}_method_modifiers" => sub { | ||||
| 268 | my ($self, $method_name) = @_; | ||||
| 269 | # NOTE: | ||||
| 270 | # for now we assume that if it exists,.. | ||||
| 271 | # it has at least one modifier in it | ||||
| 272 | (exists $self->$attr_reader->{$method_name}) ? 1 : 0; | ||||
| 273 | 3 | 62µs | 3 | 596µs | }); # spent 596µs making 3 calls to Class::MOP::Mixin::HasMethods::add_method, avg 199µs/call |
| 274 | |||||
| 275 | $META->add_method("add_${modifier_type}_method_modifier" => sub { | ||||
| 276 | 195 | 2.00ms | my ($self, $method_name, $method) = @_; | ||
| 277 | |||||
| 278 | $self->$attr_reader->{$method_name} = [] # spent 446µs making 44 calls to Moose::Meta::Role::get_around_method_modifiers_map, avg 10µs/call
# spent 226µs making 25 calls to Moose::Meta::Role::get_after_method_modifiers_map, avg 9µs/call
# spent 68µs making 8 calls to Moose::Meta::Role::get_before_method_modifiers_map, avg 8µs/call | ||||
| 279 | unless exists $self->$attr_reader->{$method_name}; | ||||
| 280 | |||||
| 281 | my $modifiers = $self->$attr_reader->{$method_name}; # spent 161µs making 22 calls to Moose::Meta::Role::get_around_method_modifiers_map, avg 7µs/call
# spent 88µs making 13 calls to Moose::Meta::Role::get_after_method_modifiers_map, avg 7µs/call
# spent 30µs making 4 calls to Moose::Meta::Role::get_before_method_modifiers_map, avg 8µs/call | ||||
| 282 | |||||
| 283 | # NOTE: | ||||
| 284 | # check to see that we aren't adding the | ||||
| 285 | # same code twice. We err in favor of the | ||||
| 286 | # first on here, this may not be as expected | ||||
| 287 | foreach my $modifier (@{$modifiers}) { | ||||
| 288 | return if $modifier == $method; | ||||
| 289 | } | ||||
| 290 | |||||
| 291 | push @{$modifiers} => $method; | ||||
| 292 | 3 | 70µs | 3 | 523µs | }); # spent 523µs making 3 calls to Class::MOP::Mixin::HasMethods::add_method, avg 174µs/call |
| 293 | |||||
| 294 | } | ||||
| 295 | |||||
| 296 | ## ------------------------------------------------------------------ | ||||
| 297 | ## override method mofidiers | ||||
| 298 | |||||
| 299 | $META->add_attribute('override_method_modifiers' => ( | ||||
| 300 | reader => 'get_override_method_modifiers_map', | ||||
| 301 | 34 | 364µs | # spent 238µs within Moose::Meta::Role::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/Moose/Meta/Role.pm:301] which was called 34 times, avg 7µs/call:
# 27 times (196µs+0s) by Moose::Meta::Role::_new at line 73 of (eval 0)[Class/MOP/Method/Generated.pm:54] at line 54 of Class/MOP/Method/Generated.pm, avg 7µs/call
# 4 times (22µs+0s) by Moose::Meta::Role::Composite::_new at line 81 of (eval 0)[Class/MOP/Method/Generated.pm:54] at line 54 of Class/MOP/Method/Generated.pm, avg 5µs/call
# 3 times (21µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm, avg 7µs/call | ||
| 302 | 1 | 14µs | 1 | 1.81ms | )); # spent 1.81ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute |
| 303 | |||||
| 304 | # NOTE: | ||||
| 305 | # these are a little different because there | ||||
| 306 | # can only be one per name, whereas the other | ||||
| 307 | # method modifiers can have multiples. | ||||
| 308 | # - SL | ||||
| 309 | |||||
| 310 | # spent 504µs (59+445) within Moose::Meta::Role::add_override_method_modifier which was called 2 times, avg 252µs/call:
# 2 times (59µs+445µs) by Moose::Role::override at line 80 of Moose/Role.pm, avg 252µs/call | ||||
| 311 | 6 | 50µs | my ($self, $method_name, $method) = @_; | ||
| 312 | (!$self->has_method($method_name)) # spent 428µs making 2 calls to Class::MOP::Mixin::HasMethods::has_method, avg 214µs/call | ||||
| 313 | || Moose->throw_error("Cannot add an override of method '$method_name' " . | ||||
| 314 | "because there is a local version of '$method_name'"); | ||||
| 315 | $self->get_override_method_modifiers_map->{$method_name} = $method; # spent 17µs making 2 calls to Moose::Meta::Role::get_override_method_modifiers_map, avg 8µs/call | ||||
| 316 | } | ||||
| 317 | |||||
| 318 | sub has_override_method_modifier { | ||||
| 319 | my ($self, $method_name) = @_; | ||||
| 320 | # NOTE: | ||||
| 321 | # for now we assume that if it exists,.. | ||||
| 322 | # it has at least one modifier in it | ||||
| 323 | (exists $self->get_override_method_modifiers_map->{$method_name}) ? 1 : 0; | ||||
| 324 | } | ||||
| 325 | |||||
| 326 | # spent 48µs (33+14) within Moose::Meta::Role::get_override_method_modifier which was called 2 times, avg 24µs/call:
# 2 times (33µs+14µs) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 202 of Moose/Meta/Role/Application/ToClass.pm, avg 24µs/call | ||||
| 327 | 4 | 27µs | my ($self, $method_name) = @_; | ||
| 328 | $self->get_override_method_modifiers_map->{$method_name}; # spent 14µs making 2 calls to Moose::Meta::Role::get_override_method_modifiers_map, avg 7µs/call | ||||
| 329 | } | ||||
| 330 | |||||
| 331 | ## general list accessor ... | ||||
| 332 | |||||
| 333 | # spent 6.72ms (5.09+1.63) within Moose::Meta::Role::get_method_modifier_list which was called 180 times, avg 37µs/call:
# 78 times (1.87ms+740µs) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 214 of Moose/Meta/Role/Application/ToClass.pm, avg 33µs/call
# 33 times (1.06ms+263µs) by Moose::Meta::Role::Application::ToRole::apply_method_modifiers at line 162 of Moose/Meta/Role/Application/ToRole.pm, avg 40µs/call
# 26 times (729µs+245µs) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 192 of Moose/Meta/Role/Application/ToClass.pm, avg 37µs/call
# 24 times (815µs+210µs) by Moose::Meta::Role::Application::RoleSummation::apply_method_modifiers at line 245 of Moose/Meta/Role/Application/RoleSummation.pm, avg 43µs/call
# 11 times (394µs+102µs) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 122 of Moose/Meta/Role/Application/ToRole.pm, avg 45µs/call
# 8 times (222µs+70µs) by Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers at line 208 of Moose/Meta/Role/Application/RoleSummation.pm, avg 36µs/call | ||||
| 334 | 540 | 4.21ms | my ($self, $modifier_type) = @_; | ||
| 335 | my $accessor = "get_${modifier_type}_method_modifiers_map"; | ||||
| 336 | keys %{$self->$accessor}; # spent 456µs making 45 calls to Moose::Meta::Role::get_after_method_modifiers_map, avg 10µs/call
# spent 417µs making 45 calls to Moose::Meta::Role::get_override_method_modifiers_map, avg 9µs/call
# spent 380µs making 45 calls to Moose::Meta::Role::get_around_method_modifiers_map, avg 8µs/call
# spent 377µs making 45 calls to Moose::Meta::Role::get_before_method_modifiers_map, avg 8µs/call | ||||
| 337 | } | ||||
| 338 | |||||
| 339 | 11 | 154µs | # spent 124µs within Moose::Meta::Role::reset_package_cache_flag which was called 11 times, avg 11µs/call:
# 11 times (124µs+0s) by Moose::Meta::Role::add_role at line 360, avg 11µs/call | ||
| 340 | sub update_package_cache_flag { | ||||
| 341 | my $self = shift; | ||||
| 342 | $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name); | ||||
| 343 | } | ||||
| 344 | |||||
| 345 | |||||
| 346 | |||||
| 347 | ## ------------------------------------------------------------------ | ||||
| 348 | ## subroles | ||||
| 349 | |||||
| 350 | $META->add_attribute('roles' => ( | ||||
| 351 | reader => 'get_roles', | ||||
| 352 | 30 | 378µs | # spent 285µs within Moose::Meta::Role::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/Moose/Meta/Role.pm:352] which was called 30 times, avg 10µs/call:
# 27 times (262µs+0s) by Moose::Meta::Role::_new at line 36 of (eval 0)[Class/MOP/Method/Generated.pm:54] at line 54 of Class/MOP/Method/Generated.pm, avg 10µs/call
# 3 times (23µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm, avg 8µs/call | ||
| 353 | 1 | 14µs | 1 | 1.88ms | )); # spent 1.88ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute |
| 354 | |||||
| 355 | # spent 1.09ms (604µs+485µs) within Moose::Meta::Role::add_role which was called 11 times, avg 99µs/call:
# 11 times (604µs+485µs) by Moose::Meta::Role::Application::ToRole::apply at line 18 of Moose/Meta/Role/Application/ToRole.pm, avg 99µs/call | ||||
| 356 | 44 | 820µs | my ($self, $role) = @_; | ||
| 357 | (blessed($role) && $role->isa('Moose::Meta::Role')) # spent 60µs making 11 calls to Scalar::Util::blessed, avg 5µs/call
# spent 41µs making 11 calls to UNIVERSAL::isa, avg 4µs/call | ||||
| 358 | || Moose->throw_error("Roles must be instances of Moose::Meta::Role"); | ||||
| 359 | push @{$self->get_roles} => $role; # spent 261µs making 11 calls to Moose::Meta::Role::get_roles, avg 24µs/call | ||||
| 360 | $self->reset_package_cache_flag; # spent 124µs making 11 calls to Moose::Meta::Role::reset_package_cache_flag, avg 11µs/call | ||||
| 361 | } | ||||
| 362 | |||||
| 363 | sub calculate_all_roles { | ||||
| 364 | my $self = shift; | ||||
| 365 | my %seen; | ||||
| 366 | grep { | ||||
| 367 | !$seen{$_->name}++ | ||||
| 368 | } ($self, map { | ||||
| 369 | $_->calculate_all_roles | ||||
| 370 | } @{ $self->get_roles }); | ||||
| 371 | } | ||||
| 372 | |||||
| 373 | # spent 7.41ms (5.44+1.98) within Moose::Meta::Role::does_role which was called 163 times, avg 45µs/call:
# 155 times (5.25ms+2.16ms) by Moose::Meta::Class::does_role at line 226 of Moose/Meta/Class.pm, avg 48µs/call
# 8 times (181µs+-181µs) by Moose::Meta::Role::does_role at line 382, avg 0s/call | ||||
| 374 | 720 | 7.18ms | my ($self, $role) = @_; | ||
| 375 | (defined $role) | ||||
| 376 | || Moose->throw_error("You must supply a role name to look for"); | ||||
| 377 | my $role_name = blessed $role ? $role->name : $role; # spent 761µs making 163 calls to Scalar::Util::blessed, avg 5µs/call | ||||
| 378 | # if we are it,.. then return true | ||||
| 379 | return 1 if $role_name eq $self->name; # spent 921µs making 163 calls to Class::MOP::Package::name, avg 6µs/call | ||||
| 380 | # otherwise.. check our children | ||||
| 381 | foreach my $role (@{$self->get_roles}) { # spent 297µs making 34 calls to Moose::Meta::Role::get_roles, avg 9µs/call | ||||
| 382 | return 1 if $role->does_role($role_name); # spent 240µs making 8 calls to Moose::Meta::Role::does_role, avg 30µs/call, recursion: max depth 1, time 240µs | ||||
| 383 | } | ||||
| 384 | return 0; | ||||
| 385 | } | ||||
| 386 | |||||
| 387 | 12 | 222µs | 12 | 3.77ms | # spent 3.99ms (224µs+3.77) within Moose::Meta::Role::find_method_by_name which was called 12 times, avg 333µs/call:
# 12 times (224µs+3.77ms) by Moose::Meta::Role::Application::ToRole::check_required_methods at line 43 of Moose/Meta/Role/Application/ToRole.pm, avg 333µs/call # spent 3.77ms making 12 calls to Class::MOP::Mixin::HasMethods::get_method, avg 314µs/call |
| 388 | |||||
| 389 | sub alias_method { | ||||
| 390 | Carp::cluck("The alias_method method is deprecated. Use add_method instead.\n"); | ||||
| 391 | |||||
| 392 | my $self = shift; | ||||
| 393 | |||||
| 394 | $self->add_method(@_); | ||||
| 395 | } | ||||
| 396 | |||||
| 397 | ## ------------------------------------------------------------------ | ||||
| 398 | ## role construction | ||||
| 399 | ## ------------------------------------------------------------------ | ||||
| 400 | |||||
| 401 | # spent 836ms (3.10+833) within Moose::Meta::Role::apply which was called 37 times, avg 22.6ms/call:
# 33 times (2.81ms+804ms) by Moose::Util::_apply_all_roles at line 132 of Moose/Util.pm, avg 24.5ms/call
# 4 times (296µs+28.5ms) by Moose::Util::_apply_all_roles at line 135 of Moose/Util.pm, avg 7.21ms/call | ||||
| 402 | 222 | 3.42ms | my ($self, $other, @args) = @_; | ||
| 403 | |||||
| 404 | (blessed($other)) # spent 151µs making 37 calls to Scalar::Util::blessed, avg 4µs/call | ||||
| 405 | || Moose->throw_error("You must pass in an blessed instance"); | ||||
| 406 | |||||
| 407 | my $application_class; | ||||
| 408 | if ($other->isa('Moose::Meta::Role')) { # spent 361µs making 63 calls to UNIVERSAL::isa, avg 6µs/call
# spent 274µs making 26 calls to Moose::Meta::Role::application_to_class_class, avg 11µs/call
# spent 103µs making 11 calls to Moose::Meta::Role::application_to_role_class, avg 9µs/call | ||||
| 409 | $application_class = $self->application_to_role_class; | ||||
| 410 | } | ||||
| 411 | elsif ($other->isa('Moose::Meta::Class')) { | ||||
| 412 | $application_class = $self->application_to_class_class; | ||||
| 413 | } | ||||
| 414 | else { | ||||
| 415 | $application_class = $self->application_to_instance_class; | ||||
| 416 | } | ||||
| 417 | |||||
| 418 | Class::MOP::load_class($application_class); # spent 5.68ms making 37 calls to Class::MOP::load_class, avg 154µs/call, recursion: max depth 2, time 4.17ms | ||||
| 419 | return $application_class->new(@args)->apply($self, $other); # spent 692ms making 26 calls to Moose::Meta::Role::Application::ToClass::apply, avg 26.6ms/call
# spent 72.8ms making 10 calls to Moose::Meta::Role::Application::ToRole::apply, avg 7.28ms/call
# spent 40.6ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::2::apply
# spent 20.7ms making 37 calls to Moose::Meta::Role::Application::new, avg 561µs/call | ||||
| 420 | } | ||||
| 421 | |||||
| 422 | 8 | 68µs | # spent 40µs within Moose::Meta::Role::composition_class_roles which was called 8 times, avg 5µs/call:
# 8 times (40µs+0s) by Moose::Meta::Role::Composite::new at line 50 of Moose/Meta/Role/Composite.pm, avg 5µs/call | ||
| 423 | |||||
| 424 | # spent 81.0ms (669µs+80.4) within Moose::Meta::Role::combine which was called 4 times, avg 20.3ms/call:
# 4 times (669µs+80.4ms) by Moose::Util::_apply_all_roles at line 135 of Moose/Util.pm, avg 20.3ms/call | ||||
| 425 | 64 | 568µs | my ($class, @role_specs) = @_; | ||
| 426 | |||||
| 427 | require Moose::Meta::Role::Composite; | ||||
| 428 | |||||
| 429 | my (@roles, %role_params); | ||||
| 430 | while (@role_specs) { | ||||
| 431 | my ($role, $params) = @{ splice @role_specs, 0, 1 }; | ||||
| 432 | my $requested_role # spent 38µs making 8 calls to Scalar::Util::blessed, avg 5µs/call | ||||
| 433 | = blessed $role | ||||
| 434 | ? $role | ||||
| 435 | : Class::MOP::class_of($role); | ||||
| 436 | |||||
| 437 | my $actual_role = $requested_role->_role_for_combination($params); # spent 62µs making 8 calls to Moose::Meta::Role::_role_for_combination, avg 8µs/call | ||||
| 438 | push @roles => $actual_role; | ||||
| 439 | |||||
| 440 | next unless defined $params; | ||||
| 441 | $role_params{$actual_role->name} = $params; | ||||
| 442 | } | ||||
| 443 | |||||
| 444 | my $c = Moose::Meta::Role::Composite->new(roles => \@roles); # spent 2.67ms making 4 calls to Moose::Meta::Role::Composite::new, avg 668µs/call | ||||
| 445 | return $c->apply_params(\%role_params); # spent 77.6ms making 4 calls to Moose::Meta::Role::Composite::apply_params, avg 19.4ms/call | ||||
| 446 | } | ||||
| 447 | |||||
| 448 | # spent 62µs within Moose::Meta::Role::_role_for_combination which was called 8 times, avg 8µs/call:
# 8 times (62µs+0s) by Moose::Meta::Role::combine at line 437, avg 8µs/call | ||||
| 449 | 16 | 129µs | my ($self, $params) = @_; | ||
| 450 | return $self; | ||||
| 451 | } | ||||
| 452 | |||||
| 453 | sub create { | ||||
| 454 | my ( $role, $package_name, %options ) = @_; | ||||
| 455 | |||||
| 456 | $options{package} = $package_name; | ||||
| 457 | |||||
| 458 | (ref $options{attributes} eq 'HASH') | ||||
| 459 | || confess "You must pass a HASH ref of attributes" | ||||
| 460 | if exists $options{attributes}; | ||||
| 461 | |||||
| 462 | (ref $options{methods} eq 'HASH') | ||||
| 463 | || confess "You must pass a HASH ref of methods" | ||||
| 464 | if exists $options{methods}; | ||||
| 465 | |||||
| 466 | my (%initialize_options) = %options; | ||||
| 467 | delete @initialize_options{qw( | ||||
| 468 | package | ||||
| 469 | attributes | ||||
| 470 | methods | ||||
| 471 | version | ||||
| 472 | authority | ||||
| 473 | )}; | ||||
| 474 | |||||
| 475 | my $meta = $role->initialize( $package_name => %initialize_options ); | ||||
| 476 | |||||
| 477 | $meta->_instantiate_module( $options{version}, $options{authority} ); | ||||
| 478 | |||||
| 479 | # FIXME totally lame | ||||
| 480 | $meta->add_method('meta' => sub { | ||||
| 481 | $role->initialize(ref($_[0]) || $_[0]); | ||||
| 482 | }); | ||||
| 483 | |||||
| 484 | if (exists $options{attributes}) { | ||||
| 485 | foreach my $attribute_name (keys %{$options{attributes}}) { | ||||
| 486 | my $attr = $options{attributes}->{$attribute_name}; | ||||
| 487 | $meta->add_attribute( | ||||
| 488 | $attribute_name => blessed $attr ? $attr : %{$attr} ); | ||||
| 489 | } | ||||
| 490 | } | ||||
| 491 | |||||
| 492 | if (exists $options{methods}) { | ||||
| 493 | foreach my $method_name (keys %{$options{methods}}) { | ||||
| 494 | $meta->add_method($method_name, $options{methods}->{$method_name}); | ||||
| 495 | } | ||||
| 496 | } | ||||
| 497 | |||||
| 498 | Class::MOP::weaken_metaclass($meta->name) | ||||
| 499 | if $meta->is_anon_role; | ||||
| 500 | |||||
| 501 | return $meta; | ||||
| 502 | } | ||||
| 503 | |||||
| 504 | # anonymous roles. most of it is copied straight out of Class::MOP::Class. | ||||
| 505 | # an intrepid hacker might find great riches if he unifies this code with that | ||||
| 506 | # code in Class::MOP::Module or Class::MOP::Package | ||||
| 507 | { | ||||
| 508 | # NOTE: | ||||
| 509 | # this should be sufficient, if you have a | ||||
| 510 | # use case where it is not, write a test and | ||||
| 511 | # I will change it. | ||||
| 512 | 2 | 6µs | my $ANON_ROLE_SERIAL = 0; | ||
| 513 | |||||
| 514 | # NOTE: | ||||
| 515 | # we need a sufficiently annoying prefix | ||||
| 516 | # this should suffice for now, this is | ||||
| 517 | # used in a couple of places below, so | ||||
| 518 | # need to put it up here for now. | ||||
| 519 | 1 | 4µs | my $ANON_ROLE_PREFIX = 'Moose::Meta::Role::__ANON__::SERIAL::'; | ||
| 520 | |||||
| 521 | sub is_anon_role { | ||||
| 522 | my $self = shift; | ||||
| 523 | 3 | 280µs | 2 | 168µs | # spent 98µs (27+71) within Moose::Meta::Role::BEGIN@523 which was called
# once (27µs+71µs) by Moose::BEGIN@26 at line 523 # spent 98µs making 1 call to Moose::Meta::Role::BEGIN@523
# spent 71µs making 1 call to warnings::unimport |
| 524 | $self->name =~ /^$ANON_ROLE_PREFIX/; | ||||
| 525 | } | ||||
| 526 | |||||
| 527 | sub create_anon_role { | ||||
| 528 | my ($role, %options) = @_; | ||||
| 529 | my $package_name = $ANON_ROLE_PREFIX . ++$ANON_ROLE_SERIAL; | ||||
| 530 | return $role->create($package_name, %options); | ||||
| 531 | } | ||||
| 532 | |||||
| 533 | # NOTE: | ||||
| 534 | # this will only get called for | ||||
| 535 | # anon-roles, all other calls | ||||
| 536 | # are assumed to occur during | ||||
| 537 | # global destruction and so don't | ||||
| 538 | # really need to be handled explicitly | ||||
| 539 | # spent 245µs (144+100) within Moose::Meta::Role::DESTROY which was called 3 times, avg 82µs/call:
# 2 times (105µs+81µs) by MooseX::Role::WithOverloading::init_meta at line 354 of Moose/Exporter.pm, avg 93µs/call
# once (40µs+19µs) by Moose::Role::with at line 7 of Catalyst/Exception/Basic.pm | ||||
| 540 | 9 | 368µs | my $self = shift; | ||
| 541 | |||||
| 542 | return if in_global_destruction(); # it'll happen soon anyway and this just makes things more complicated # spent 32µs making 3 calls to Devel::GlobalDestruction::in_global_destruction, avg 11µs/call | ||||
| 543 | |||||
| 544 | 3 | 105µs | 2 | 74µs | # spent 48µs (21+27) within Moose::Meta::Role::BEGIN@544 which was called
# once (21µs+27µs) by Moose::BEGIN@26 at line 544 # spent 48µs making 1 call to Moose::Meta::Role::BEGIN@544
# spent 27µs making 1 call to warnings::unimport |
| 545 | return unless $self->name =~ /^$ANON_ROLE_PREFIX/; # spent 47µs making 3 calls to Moose::Meta::Role::CORE:regcomp, avg 16µs/call
# spent 15µs making 3 calls to Class::MOP::Package::name, avg 5µs/call
# spent 6µs making 3 calls to Moose::Meta::Role::CORE:match, avg 2µs/call | ||||
| 546 | |||||
| 547 | # XXX: is this necessary for us? I don't understand what it's doing | ||||
| 548 | # -sartak | ||||
| 549 | |||||
| 550 | # Moose does a weird thing where it replaces the metaclass for | ||||
| 551 | # class when fixing metaclass incompatibility. In that case, | ||||
| 552 | # we don't want to clean out the namespace now. We can detect | ||||
| 553 | # that because Moose will explicitly update the singleton | ||||
| 554 | # cache in Class::MOP. | ||||
| 555 | #my $current_meta = Class::MOP::get_metaclass_by_name($self->name); | ||||
| 556 | #return if $current_meta ne $self; | ||||
| 557 | |||||
| 558 | my ($serial_id) = ($self->name =~ /^$ANON_ROLE_PREFIX(\d+)/); | ||||
| 559 | 3 | 243µs | 2 | 83µs | # spent 52µs (20+32) within Moose::Meta::Role::BEGIN@559 which was called
# once (20µs+32µs) by Moose::BEGIN@26 at line 559 # spent 52µs making 1 call to Moose::Meta::Role::BEGIN@559
# spent 32µs making 1 call to strict::unimport |
| 560 | foreach my $key (keys %{$ANON_ROLE_PREFIX . $serial_id}) { | ||||
| 561 | delete ${$ANON_ROLE_PREFIX . $serial_id}{$key}; | ||||
| 562 | } | ||||
| 563 | delete ${'main::' . $ANON_ROLE_PREFIX}{$serial_id . '::'}; | ||||
| 564 | } | ||||
| 565 | } | ||||
| 566 | |||||
| 567 | ##################################################################### | ||||
| 568 | ## NOTE: | ||||
| 569 | ## This is Moose::Meta::Role as defined by Moose (plus the use of | ||||
| 570 | ## MooseX::AttributeHelpers module). It is here as a reference to | ||||
| 571 | ## make it easier to see what is happening above with all the meta | ||||
| 572 | ## programming. - SL | ||||
| 573 | ##################################################################### | ||||
| 574 | # | ||||
| 575 | # has 'roles' => ( | ||||
| 576 | # metaclass => 'Array', | ||||
| 577 | # reader => 'get_roles', | ||||
| 578 | # isa => 'ArrayRef[Moose::Meta::Role]', | ||||
| 579 | # default => sub { [] }, | ||||
| 580 | # provides => { | ||||
| 581 | # 'push' => 'add_role', | ||||
| 582 | # } | ||||
| 583 | # ); | ||||
| 584 | # | ||||
| 585 | # has 'excluded_roles_map' => ( | ||||
| 586 | # metaclass => 'Hash', | ||||
| 587 | # reader => 'get_excluded_roles_map', | ||||
| 588 | # isa => 'HashRef[Str]', | ||||
| 589 | # provides => { | ||||
| 590 | # # Not exactly set, cause it sets multiple | ||||
| 591 | # 'set' => 'add_excluded_roles', | ||||
| 592 | # 'keys' => 'get_excluded_roles_list', | ||||
| 593 | # 'exists' => 'excludes_role', | ||||
| 594 | # } | ||||
| 595 | # ); | ||||
| 596 | # | ||||
| 597 | # has 'required_methods' => ( | ||||
| 598 | # metaclass => 'Hash', | ||||
| 599 | # reader => 'get_required_methods_map', | ||||
| 600 | # isa => 'HashRef[Moose::Meta::Role::Method::Required]', | ||||
| 601 | # provides => { | ||||
| 602 | # # not exactly set, or delete since it works for multiple | ||||
| 603 | # 'set' => 'add_required_methods', | ||||
| 604 | # 'delete' => 'remove_required_methods', | ||||
| 605 | # 'keys' => 'get_required_method_list', | ||||
| 606 | # 'exists' => 'requires_method', | ||||
| 607 | # } | ||||
| 608 | # ); | ||||
| 609 | # | ||||
| 610 | # # the before, around and after modifiers are | ||||
| 611 | # # HASH keyed by method-name, with ARRAY of | ||||
| 612 | # # CODE refs to apply in that order | ||||
| 613 | # | ||||
| 614 | # has 'before_method_modifiers' => ( | ||||
| 615 | # metaclass => 'Hash', | ||||
| 616 | # reader => 'get_before_method_modifiers_map', | ||||
| 617 | # isa => 'HashRef[ArrayRef[CodeRef]]', | ||||
| 618 | # provides => { | ||||
| 619 | # 'keys' => 'get_before_method_modifiers', | ||||
| 620 | # 'exists' => 'has_before_method_modifiers', | ||||
| 621 | # # This actually makes sure there is an | ||||
| 622 | # # ARRAY at the given key, and pushed onto | ||||
| 623 | # # it. It also checks for duplicates as well | ||||
| 624 | # # 'add' => 'add_before_method_modifier' | ||||
| 625 | # } | ||||
| 626 | # ); | ||||
| 627 | # | ||||
| 628 | # has 'after_method_modifiers' => ( | ||||
| 629 | # metaclass => 'Hash', | ||||
| 630 | # reader =>'get_after_method_modifiers_map', | ||||
| 631 | # isa => 'HashRef[ArrayRef[CodeRef]]', | ||||
| 632 | # provides => { | ||||
| 633 | # 'keys' => 'get_after_method_modifiers', | ||||
| 634 | # 'exists' => 'has_after_method_modifiers', | ||||
| 635 | # # This actually makes sure there is an | ||||
| 636 | # # ARRAY at the given key, and pushed onto | ||||
| 637 | # # it. It also checks for duplicates as well | ||||
| 638 | # # 'add' => 'add_after_method_modifier' | ||||
| 639 | # } | ||||
| 640 | # ); | ||||
| 641 | # | ||||
| 642 | # has 'around_method_modifiers' => ( | ||||
| 643 | # metaclass => 'Hash', | ||||
| 644 | # reader =>'get_around_method_modifiers_map', | ||||
| 645 | # isa => 'HashRef[ArrayRef[CodeRef]]', | ||||
| 646 | # provides => { | ||||
| 647 | # 'keys' => 'get_around_method_modifiers', | ||||
| 648 | # 'exists' => 'has_around_method_modifiers', | ||||
| 649 | # # This actually makes sure there is an | ||||
| 650 | # # ARRAY at the given key, and pushed onto | ||||
| 651 | # # it. It also checks for duplicates as well | ||||
| 652 | # # 'add' => 'add_around_method_modifier' | ||||
| 653 | # } | ||||
| 654 | # ); | ||||
| 655 | # | ||||
| 656 | # # override is similar to the other modifiers | ||||
| 657 | # # except that it is not an ARRAY of code refs | ||||
| 658 | # # but instead just a single name->code mapping | ||||
| 659 | # | ||||
| 660 | # has 'override_method_modifiers' => ( | ||||
| 661 | # metaclass => 'Hash', | ||||
| 662 | # reader =>'get_override_method_modifiers_map', | ||||
| 663 | # isa => 'HashRef[CodeRef]', | ||||
| 664 | # provides => { | ||||
| 665 | # 'keys' => 'get_override_method_modifier', | ||||
| 666 | # 'exists' => 'has_override_method_modifier', | ||||
| 667 | # 'add' => 'add_override_method_modifier', # checks for local method .. | ||||
| 668 | # } | ||||
| 669 | # ); | ||||
| 670 | # | ||||
| 671 | ##################################################################### | ||||
| 672 | |||||
| 673 | |||||
| 674 | 1 | 1.11ms | 1; | ||
| 675 | |||||
| 676 | __END__ | ||||
| 677 | |||||
| 678 | =pod | ||||
| 679 | |||||
| 680 | =head1 NAME | ||||
| 681 | |||||
| 682 | Moose::Meta::Role - The Moose Role metaclass | ||||
| 683 | |||||
| 684 | =head1 DESCRIPTION | ||||
| 685 | |||||
| 686 | This class is a subclass of L<Class::MOP::Module> that provides | ||||
| 687 | additional Moose-specific functionality. | ||||
| 688 | |||||
| 689 | It's API looks a lot like L<Moose::Meta::Class>, but internally it | ||||
| 690 | implements many things differently. This may change in the future. | ||||
| 691 | |||||
| 692 | =head1 INHERITANCE | ||||
| 693 | |||||
| 694 | C<Moose::Meta::Role> is a subclass of L<Class::MOP::Module>. | ||||
| 695 | |||||
| 696 | =head1 METHODS | ||||
| 697 | |||||
| 698 | =head2 Construction | ||||
| 699 | |||||
| 700 | =over 4 | ||||
| 701 | |||||
| 702 | =item B<< Moose::Meta::Role->initialize($role_name) >> | ||||
| 703 | |||||
| 704 | This method creates a new role object with the provided name. | ||||
| 705 | |||||
| 706 | =item B<< Moose::Meta::Role->combine( [ $role => { ... } ], [ $role ], ... ) >> | ||||
| 707 | |||||
| 708 | This method accepts a list of array references. Each array reference | ||||
| 709 | should contain a role name or L<Moose::Meta::Role> object as its first element. The second element is | ||||
| 710 | an optional hash reference. The hash reference can contain C<-excludes> | ||||
| 711 | and C<-alias> keys to control how methods are composed from the role. | ||||
| 712 | |||||
| 713 | The return value is a new L<Moose::Meta::Role::Composite> that | ||||
| 714 | represents the combined roles. | ||||
| 715 | |||||
| 716 | =item B<< $metarole->composition_class_roles >> | ||||
| 717 | |||||
| 718 | When combining multiple roles using C<combine>, this method is used to obtain a | ||||
| 719 | list of role names to be applied to the L<Moose::Meta::Role::Composite> | ||||
| 720 | instance returned by C<combine>. The default implementation returns an empty | ||||
| 721 | list. Extensions that need to hook into role combination may wrap this method | ||||
| 722 | to return additional role names. | ||||
| 723 | |||||
| 724 | =item B<< Moose::Meta::Role->create($name, %options) >> | ||||
| 725 | |||||
| 726 | This method is identical to the L<Moose::Meta::Class> C<create> | ||||
| 727 | method. | ||||
| 728 | |||||
| 729 | =item B<< Moose::Meta::Role->create_anon_role >> | ||||
| 730 | |||||
| 731 | This method is identical to the L<Moose::Meta::Class> | ||||
| 732 | C<create_anon_class> method. | ||||
| 733 | |||||
| 734 | =item B<< $metarole->is_anon_role >> | ||||
| 735 | |||||
| 736 | Returns true if the role is an anonymous role. | ||||
| 737 | |||||
| 738 | =back | ||||
| 739 | |||||
| 740 | =head2 Role application | ||||
| 741 | |||||
| 742 | =over 4 | ||||
| 743 | |||||
| 744 | =item B<< $metarole->apply( $thing, @options ) >> | ||||
| 745 | |||||
| 746 | This method applies a role to the given C<$thing>. That can be another | ||||
| 747 | L<Moose::Meta::Role>, object, a L<Moose::Meta::Class> object, or a | ||||
| 748 | (non-meta) object instance. | ||||
| 749 | |||||
| 750 | The options are passed directly to the constructor for the appropriate | ||||
| 751 | L<Moose::Meta::Role::Application> subclass. | ||||
| 752 | |||||
| 753 | Note that this will apply the role even if the C<$thing> in question already | ||||
| 754 | C<does> this role. L<Moose::Util/does_role> is a convenient wrapper for | ||||
| 755 | finding out if role application is necessary. | ||||
| 756 | |||||
| 757 | =back | ||||
| 758 | |||||
| 759 | =head2 Roles and other roles | ||||
| 760 | |||||
| 761 | =over 4 | ||||
| 762 | |||||
| 763 | =item B<< $metarole->get_roles >> | ||||
| 764 | |||||
| 765 | This returns an array reference of roles which this role does. This | ||||
| 766 | list may include duplicates. | ||||
| 767 | |||||
| 768 | =item B<< $metarole->calculate_all_roles >> | ||||
| 769 | |||||
| 770 | This returns a I<unique> list of all roles that this role does, and | ||||
| 771 | all the roles that its roles do. | ||||
| 772 | |||||
| 773 | =item B<< $metarole->does_role($role) >> | ||||
| 774 | |||||
| 775 | Given a role I<name> or L<Moose::Meta::Role> object, returns true if this role | ||||
| 776 | does the given role. | ||||
| 777 | |||||
| 778 | =item B<< $metarole->add_role($role) >> | ||||
| 779 | |||||
| 780 | Given a L<Moose::Meta::Role> object, this adds the role to the list of | ||||
| 781 | roles that the role does. | ||||
| 782 | |||||
| 783 | =item B<< $metarole->get_excluded_roles_list >> | ||||
| 784 | |||||
| 785 | Returns a list of role names which this role excludes. | ||||
| 786 | |||||
| 787 | =item B<< $metarole->excludes_role($role_name) >> | ||||
| 788 | |||||
| 789 | Given a role I<name>, returns true if this role excludes the named | ||||
| 790 | role. | ||||
| 791 | |||||
| 792 | =item B<< $metarole->add_excluded_roles(@role_names) >> | ||||
| 793 | |||||
| 794 | Given one or more role names, adds those roles to the list of excluded | ||||
| 795 | roles. | ||||
| 796 | |||||
| 797 | =back | ||||
| 798 | |||||
| 799 | =head2 Methods | ||||
| 800 | |||||
| 801 | The methods for dealing with a role's methods are all identical in API | ||||
| 802 | and behavior to the same methods in L<Class::MOP::Class>. | ||||
| 803 | |||||
| 804 | =over 4 | ||||
| 805 | |||||
| 806 | =item B<< $metarole->method_metaclass >> | ||||
| 807 | |||||
| 808 | Returns the method metaclass name for the role. This defaults to | ||||
| 809 | L<Moose::Meta::Role::Method>. | ||||
| 810 | |||||
| 811 | =item B<< $metarole->get_method($name) >> | ||||
| 812 | |||||
| 813 | =item B<< $metarole->has_method($name) >> | ||||
| 814 | |||||
| 815 | =item B<< $metarole->add_method( $name, $body ) >> | ||||
| 816 | |||||
| 817 | =item B<< $metarole->get_method_list >> | ||||
| 818 | |||||
| 819 | =item B<< $metarole->find_method_by_name($name) >> | ||||
| 820 | |||||
| 821 | These methods are all identical to the methods of the same name in | ||||
| 822 | L<Class::MOP::Package> | ||||
| 823 | |||||
| 824 | =back | ||||
| 825 | |||||
| 826 | =head2 Attributes | ||||
| 827 | |||||
| 828 | As with methods, the methods for dealing with a role's attribute are | ||||
| 829 | all identical in API and behavior to the same methods in | ||||
| 830 | L<Class::MOP::Class>. | ||||
| 831 | |||||
| 832 | However, attributes stored in this class are I<not> stored as | ||||
| 833 | objects. Rather, the attribute definition is stored as a hash | ||||
| 834 | reference. When a role is composed into a class, this hash reference | ||||
| 835 | is passed directly to the metaclass's C<add_attribute> method. | ||||
| 836 | |||||
| 837 | This is quite likely to change in the future. | ||||
| 838 | |||||
| 839 | =over 4 | ||||
| 840 | |||||
| 841 | =item B<< $metarole->get_attribute($attribute_name) >> | ||||
| 842 | |||||
| 843 | =item B<< $metarole->has_attribute($attribute_name) >> | ||||
| 844 | |||||
| 845 | =item B<< $metarole->get_attribute_list >> | ||||
| 846 | |||||
| 847 | =item B<< $metarole->add_attribute($name, %options) >> | ||||
| 848 | |||||
| 849 | =item B<< $metarole->remove_attribute($attribute_name) >> | ||||
| 850 | |||||
| 851 | =back | ||||
| 852 | |||||
| 853 | =head2 Required methods | ||||
| 854 | |||||
| 855 | =over 4 | ||||
| 856 | |||||
| 857 | =item B<< $metarole->get_required_method_list >> | ||||
| 858 | |||||
| 859 | Returns the list of methods required by the role. | ||||
| 860 | |||||
| 861 | =item B<< $metarole->requires_method($name) >> | ||||
| 862 | |||||
| 863 | Returns true if the role requires the named method. | ||||
| 864 | |||||
| 865 | =item B<< $metarole->add_required_methods(@names) >> | ||||
| 866 | |||||
| 867 | Adds the named methods to the role's list of required methods. | ||||
| 868 | |||||
| 869 | =item B<< $metarole->remove_required_methods(@names) >> | ||||
| 870 | |||||
| 871 | Removes the named methods from the role's list of required methods. | ||||
| 872 | |||||
| 873 | =item B<< $metarole->add_conflicting_method(%params) >> | ||||
| 874 | |||||
| 875 | Instantiate the parameters as a L<Moose::Meta::Role::Method::Conflicting> | ||||
| 876 | object, then add it to the required method list. | ||||
| 877 | |||||
| 878 | =back | ||||
| 879 | |||||
| 880 | =head2 Method modifiers | ||||
| 881 | |||||
| 882 | These methods act like their counterparts in L<Class::MOP::Class> and | ||||
| 883 | L<Moose::Meta::Class>. | ||||
| 884 | |||||
| 885 | However, method modifiers are simply stored internally, and are not | ||||
| 886 | applied until the role itself is applied to a class. | ||||
| 887 | |||||
| 888 | =over 4 | ||||
| 889 | |||||
| 890 | =item B<< $metarole->add_after_method_modifier($method_name, $method) >> | ||||
| 891 | |||||
| 892 | =item B<< $metarole->add_around_method_modifier($method_name, $method) >> | ||||
| 893 | |||||
| 894 | =item B<< $metarole->add_before_method_modifier($method_name, $method) >> | ||||
| 895 | |||||
| 896 | =item B<< $metarole->add_override_method_modifier($method_name, $method) >> | ||||
| 897 | |||||
| 898 | These methods all add an appropriate modifier to the internal list of | ||||
| 899 | modifiers. | ||||
| 900 | |||||
| 901 | =item B<< $metarole->has_after_method_modifiers >> | ||||
| 902 | |||||
| 903 | =item B<< $metarole->has_around_method_modifiers >> | ||||
| 904 | |||||
| 905 | =item B<< $metarole->has_before_method_modifiers >> | ||||
| 906 | |||||
| 907 | =item B<< $metarole->has_override_method_modifier >> | ||||
| 908 | |||||
| 909 | Return true if the role has any modifiers of the given type. | ||||
| 910 | |||||
| 911 | =item B<< $metarole->get_after_method_modifiers($method_name) >> | ||||
| 912 | |||||
| 913 | =item B<< $metarole->get_around_method_modifiers($method_name) >> | ||||
| 914 | |||||
| 915 | =item B<< $metarole->get_before_method_modifiers($method_name) >> | ||||
| 916 | |||||
| 917 | Given a method name, returns a list of the appropriate modifiers for | ||||
| 918 | that method. | ||||
| 919 | |||||
| 920 | =item B<< $metarole->get_override_method_modifier($method_name) >> | ||||
| 921 | |||||
| 922 | Given a method name, returns the override method modifier for that | ||||
| 923 | method, if it has one. | ||||
| 924 | |||||
| 925 | =back | ||||
| 926 | |||||
| 927 | =head2 Introspection | ||||
| 928 | |||||
| 929 | =over 4 | ||||
| 930 | |||||
| 931 | =item B<< Moose::Meta::Role->meta >> | ||||
| 932 | |||||
| 933 | This will return a L<Class::MOP::Class> instance for this class. | ||||
| 934 | |||||
| 935 | =back | ||||
| 936 | |||||
| 937 | =head1 BUGS | ||||
| 938 | |||||
| 939 | See L<Moose/BUGS> for details on reporting bugs. | ||||
| 940 | |||||
| 941 | =head1 AUTHOR | ||||
| 942 | |||||
| 943 | Stevan Little E<lt>stevan@iinteractive.comE<gt> | ||||
| 944 | |||||
| 945 | =head1 COPYRIGHT AND LICENSE | ||||
| 946 | |||||
| 947 | Copyright 2006-2010 by Infinity Interactive, Inc. | ||||
| 948 | |||||
| 949 | L<http://www.iinteractive.com> | ||||
| 950 | |||||
| 951 | This library is free software; you can redistribute it and/or modify | ||||
| 952 | it under the same terms as Perl itself. | ||||
| 953 | |||||
| 954 | =cut | ||||
# spent 6µs within Moose::Meta::Role::CORE:match which was called 3 times, avg 2µs/call:
# 3 times (6µs+0s) by Moose::Meta::Role::DESTROY at line 545 of Moose/Meta/Role.pm, avg 2µs/call | |||||
# spent 47µs within Moose::Meta::Role::CORE:regcomp which was called 3 times, avg 16µs/call:
# 3 times (47µs+0s) by Moose::Meta::Role::DESTROY at line 545 of Moose/Meta/Role.pm, avg 16µs/call |