← Index
NYTProf Performance Profile   « block view • line view • sub view »
For xt/tapper-mcp-scheduler-with-db-longrun.t
  Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:23:35 2012

Filename/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Meta/Role.pm
StatementsExecuted 292 statements in 4.25ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111712µs3.17msMoose::Meta::Role::::BEGIN@19Moose::Meta::Role::BEGIN@19
111286µs1.45msMoose::Meta::Role::::BEGIN@22Moose::Meta::Role::BEGIN@22
111265µs1.59msMoose::Meta::Role::::BEGIN@21Moose::Meta::Role::BEGIN@21
111254µs388µsMoose::Meta::Role::::BEGIN@20Moose::Meta::Role::BEGIN@20
411200µs16.1msMoose::Meta::Role::::applyMoose::Meta::Role::apply
1621160µs216µsMoose::Meta::Role::::get_method_modifier_listMoose::Meta::Role::get_method_modifier_list
41199µs718µsMoose::Meta::Role::::initializeMoose::Meta::Role::initialize
21188µs558µsMoose::Meta::Role::::add_attributeMoose::Meta::Role::add_attribute
21175µs238µsMoose::Meta::Role::::add_required_methodsMoose::Meta::Role::add_required_methods
31157µs67µsMoose::Meta::Role::::does_roleMoose::Meta::Role::does_role
123122µs22µsMoose::Meta::Role::::__ANON__[:308]Moose::Meta::Role::__ANON__[:308]
41118µs93µsMoose::Meta::Role::::find_method_by_nameMoose::Meta::Role::find_method_by_name
21118µs67µsMoose::Meta::Role::::_attach_attributeMoose::Meta::Role::_attach_attribute
82113µs13µsMoose::Meta::Role::::__ANON__[:91]Moose::Meta::Role::__ANON__[:91]
11110µs226µsMoose::Meta::Role::::BEGIN@16Moose::Meta::Role::BEGIN@16
11110µs49µsMoose::Meta::Role::::BEGIN@13Moose::Meta::Role::BEGIN@13
1119µs9µsMoose::Meta::Role::::BEGIN@2Moose::Meta::Role::BEGIN@2
1118µs174µsMoose::Meta::Role::::BEGIN@27Moose::Meta::Role::BEGIN@27
1118µs26µsMoose::Meta::Role::::BEGIN@10Moose::Meta::Role::BEGIN@10
4118µs8µsMoose::Meta::Role::::__ANON__[:354]Moose::Meta::Role::__ANON__[:354]
1118µs590µsMoose::Meta::Role::::BEGIN@11Moose::Meta::Role::BEGIN@11
1118µs205µsMoose::Meta::Role::::BEGIN@24Moose::Meta::Role::BEGIN@24
4117µs7µsMoose::Meta::Role::::_meta_method_classMoose::Meta::Role::_meta_method_class
1117µs10µsMoose::Meta::Role::::BEGIN@9Moose::Meta::Role::BEGIN@9
1117µs28µsMoose::Meta::Role::::BEGIN@15Moose::Meta::Role::BEGIN@15
1117µs7µsMoose::Meta::Role::::BEGIN@23Moose::Meta::Role::BEGIN@23
1117µs35µsMoose::Meta::Role::::BEGIN@14Moose::Meta::Role::BEGIN@14
4117µs7µsMoose::Meta::Role::::__ANON__[:400]Moose::Meta::Role::__ANON__[:400]
1115µs5µsMoose::Meta::Role::::BEGIN@18Moose::Meta::Role::BEGIN@18
1115µs5µsMoose::Meta::Role::::BEGIN@25Moose::Meta::Role::BEGIN@25
0000s0sMoose::Meta::Role::::__ANON__[:104]Moose::Meta::Role::__ANON__[:104]
0000s0sMoose::Meta::Role::::__ANON__[:109]Moose::Meta::Role::__ANON__[:109]
0000s0sMoose::Meta::Role::::__ANON__[:114]Moose::Meta::Role::__ANON__[:114]
0000s0sMoose::Meta::Role::::__ANON__[:119]Moose::Meta::Role::__ANON__[:119]
0000s0sMoose::Meta::Role::::__ANON__[:124]Moose::Meta::Role::__ANON__[:124]
0000s0sMoose::Meta::Role::::__ANON__[:318]Moose::Meta::Role::__ANON__[:318]
0000s0sMoose::Meta::Role::::__ANON__[:326]Moose::Meta::Role::__ANON__[:326]
0000s0sMoose::Meta::Role::::__ANON__[:345]Moose::Meta::Role::__ANON__[:345]
0000s0sMoose::Meta::Role::::__ANON__[:583]Moose::Meta::Role::__ANON__[:583]
0000s0sMoose::Meta::Role::::__ANON__[:99]Moose::Meta::Role::__ANON__[:99]
0000s0sMoose::Meta::Role::::_anon_cache_keyMoose::Meta::Role::_anon_cache_key
0000s0sMoose::Meta::Role::::_anon_package_prefixMoose::Meta::Role::_anon_package_prefix
0000s0sMoose::Meta::Role::::_restore_metaobjects_fromMoose::Meta::Role::_restore_metaobjects_from
0000s0sMoose::Meta::Role::::_role_for_combinationMoose::Meta::Role::_role_for_combination
0000s0sMoose::Meta::Role::::add_conflicting_methodMoose::Meta::Role::add_conflicting_method
0000s0sMoose::Meta::Role::::add_override_method_modifierMoose::Meta::Role::add_override_method_modifier
0000s0sMoose::Meta::Role::::add_roleMoose::Meta::Role::add_role
0000s0sMoose::Meta::Role::::calculate_all_rolesMoose::Meta::Role::calculate_all_roles
0000s0sMoose::Meta::Role::::combineMoose::Meta::Role::combine
0000s0sMoose::Meta::Role::::composition_class_rolesMoose::Meta::Role::composition_class_roles
0000s0sMoose::Meta::Role::::consumersMoose::Meta::Role::consumers
0000s0sMoose::Meta::Role::::createMoose::Meta::Role::create
0000s0sMoose::Meta::Role::::create_anon_roleMoose::Meta::Role::create_anon_role
0000s0sMoose::Meta::Role::::get_override_method_modifierMoose::Meta::Role::get_override_method_modifier
0000s0sMoose::Meta::Role::::has_override_method_modifierMoose::Meta::Role::has_override_method_modifier
0000s0sMoose::Meta::Role::::is_anon_roleMoose::Meta::Role::is_anon_role
0000s0sMoose::Meta::Role::::reinitializeMoose::Meta::Role::reinitialize
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Moose::Meta::Role;
2
# spent 9µs within Moose::Meta::Role::BEGIN@2 which was called: # once (9µs+0s) by Moose::BEGIN@36 at line 4
BEGIN {
314µs $Moose::Meta::Role::AUTHORITY = 'cpan:STEVAN';
4126µs19µs}
# spent 9µs making 1 call to Moose::Meta::Role::BEGIN@2
5{
622µs $Moose::Meta::Role::VERSION = '2.0602';
7}
8
9317µs214µs
# spent 10µs (7+3) within Moose::Meta::Role::BEGIN@9 which was called: # once (7µs+3µs) by Moose::BEGIN@36 at line 9
use strict;
# spent 10µs making 1 call to Moose::Meta::Role::BEGIN@9 # spent 3µs making 1 call to strict::import
10318µs244µs
# spent 26µs (8+18) within Moose::Meta::Role::BEGIN@10 which was called: # once (8µs+18µs) by Moose::BEGIN@36 at line 10
use warnings;
# spent 26µs making 1 call to Moose::Meta::Role::BEGIN@10 # spent 18µs making 1 call to warnings::import
11330µs21.17ms
# spent 590µs (8+582) within Moose::Meta::Role::BEGIN@11 which was called: # once (8µs+582µs) by Moose::BEGIN@36 at line 11
use metaclass;
# spent 590µs making 1 call to Moose::Meta::Role::BEGIN@11 # spent 582µs making 1 call to metaclass::import
12
13322µs289µs
# spent 49µs (10+40) within Moose::Meta::Role::BEGIN@13 which was called: # once (10µs+40µs) by Moose::BEGIN@36 at line 13
use Class::Load qw(load_class);
# spent 49µs making 1 call to Moose::Meta::Role::BEGIN@13 # spent 40µs making 1 call to Exporter::import
14318µs263µs
# spent 35µs (7+28) within Moose::Meta::Role::BEGIN@14 which was called: # once (7µs+28µs) by Moose::BEGIN@36 at line 14
use Scalar::Util 'blessed';
# spent 35µs making 1 call to Moose::Meta::Role::BEGIN@14 # spent 28µs making 1 call to Exporter::import
15318µs248µs
# spent 28µs (7+21) within Moose::Meta::Role::BEGIN@15 which was called: # once (7µs+21µs) by Moose::BEGIN@36 at line 15
use Carp 'confess';
# spent 28µs making 1 call to Moose::Meta::Role::BEGIN@15 # spent 21µs making 1 call to Exporter::import
16322µs2443µs
# spent 226µs (10+217) within Moose::Meta::Role::BEGIN@16 which was called: # once (10µs+217µs) by Moose::BEGIN@36 at line 16
use Devel::GlobalDestruction 'in_global_destruction';
# spent 226µs making 1 call to Moose::Meta::Role::BEGIN@16 # spent 217µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
17
18318µs15µs
# spent 5µs within Moose::Meta::Role::BEGIN@18 which was called: # once (5µs+0s) by Moose::BEGIN@36 at line 18
use Moose::Meta::Class;
# spent 5µs making 1 call to Moose::Meta::Role::BEGIN@18
193160µs13.17ms
# spent 3.17ms (712µs+2.46) within Moose::Meta::Role::BEGIN@19 which was called: # once (712µs+2.46ms) by Moose::BEGIN@36 at line 19
use Moose::Meta::Role::Attribute;
# spent 3.17ms making 1 call to Moose::Meta::Role::BEGIN@19
203134µs1388µs
# spent 388µs (254+134) within Moose::Meta::Role::BEGIN@20 which was called: # once (254µs+134µs) by Moose::BEGIN@36 at line 20
use Moose::Meta::Role::Method;
# spent 388µs making 1 call to Moose::Meta::Role::BEGIN@20
21389µs11.59ms
# spent 1.59ms (265µs+1.32) within Moose::Meta::Role::BEGIN@21 which was called: # once (265µs+1.32ms) by Moose::BEGIN@36 at line 21
use Moose::Meta::Role::Method::Required;
# spent 1.59ms making 1 call to Moose::Meta::Role::BEGIN@21
223135µs11.45ms
# spent 1.45ms (286µs+1.16) within Moose::Meta::Role::BEGIN@22 which was called: # once (286µs+1.16ms) by Moose::BEGIN@36 at line 22
use Moose::Meta::Role::Method::Conflicting;
# spent 1.45ms making 1 call to Moose::Meta::Role::BEGIN@22
23323µs17µs
# spent 7µs within Moose::Meta::Role::BEGIN@23 which was called: # once (7µs+0s) by Moose::BEGIN@36 at line 23
use Moose::Meta::Method::Meta;
# spent 7µs making 1 call to Moose::Meta::Role::BEGIN@23
24321µs2403µs
# spent 205µs (8+198) within Moose::Meta::Role::BEGIN@24 which was called: # once (8µs+198µs) by Moose::BEGIN@36 at line 24
use Moose::Util qw( ensure_all_roles );
# spent 205µs making 1 call to Moose::Meta::Role::BEGIN@24 # spent 198µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
25324µs15µs
# spent 5µs within Moose::Meta::Role::BEGIN@25 which was called: # once (5µs+0s) by Moose::BEGIN@36 at line 25
use Class::MOP::MiniTrait;
# spent 5µs making 1 call to Moose::Meta::Role::BEGIN@25
26
2716µs1166µs
# spent 174µs (8+166) within Moose::Meta::Role::BEGIN@27 which was called: # once (8µs+166µs) by Moose::BEGIN@36 at line 29
use base 'Class::MOP::Module',
# spent 166µs making 1 call to base::import
28 'Class::MOP::Mixin::HasAttributes',
2922.37ms1174µs 'Class::MOP::Mixin::HasMethods';
# spent 174µs making 1 call to Moose::Meta::Role::BEGIN@27
30
3117µs11.32msClass::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait');
# spent 1.32ms making 1 call to Class::MOP::MiniTrait::apply
32
33## ------------------------------------------------------------------
34## NOTE:
35## I normally don't do this, but I am doing
36## a whole bunch of meta-programmin in this
37## module, so it just makes sense. For a clearer
38## picture of what is going on in the next
39## several lines of code, look at the really
40## big comment at the end of this file (right
41## before the POD).
42## - SL
43## ------------------------------------------------------------------
44
4513µs115µsmy $META = __PACKAGE__->meta;
# spent 15µs making 1 call to Moose::Meta::Role::meta
46
47## ------------------------------------------------------------------
48## attributes ...
49
50# NOTE:
51# since roles are lazy, we hold all the attributes
52# of the individual role in 'stasis' until which
53# time when it is applied to a class. This means
54# keeping a lot of things in hash maps, so we are
55# using a little of that meta-programmin' magic
56# here an saving lots of extra typin. And since
57# many of these attributes above require similar
58# functionality to support them, so we again use
59# the wonders of meta-programmin' to deliver a
60# very compact solution to this normally verbose
61# problem.
62# - SL
63
64110µsforeach my $action (
65 {
66 name => 'excluded_roles_map',
67 attr_reader => 'get_excluded_roles_map' ,
68 methods => {
69 add => 'add_excluded_roles',
70 get_keys => 'get_excluded_roles_list',
71 existence => 'excludes_role',
72 }
73 },
74 {
75 name => 'required_methods',
76 attr_reader => 'get_required_methods_map',
77 methods => {
78 remove => 'remove_required_methods',
79 get_values => 'get_required_method_list',
80 existence => 'requires_method',
81 }
82 },
83) {
84
8521µs my $attr_reader = $action->{attr_reader};
862900ns my $methods = $action->{methods};
87
88 # create the attribute
89 $META->add_attribute($action->{name} => (
90 reader => $attr_reader,
91820µs
# spent 13µs within Moose::Meta::Role::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Meta/Role.pm:91] which was called 8 times, avg 2µs/call: # 4 times (7µs+0s) by Moose::Meta::Role::_new at line 84 of (eval 189)[Eval/Closure.pm:125], avg 2µs/call # 4 times (6µs+0s) by Moose::Meta::Role::_new at line 114 of (eval 189)[Eval/Closure.pm:125], avg 1µs/call
default => sub { {} },
92210µs4717µs Class::MOP::_definition_context(),
# spent 700µs making 2 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 350µs/call # spent 17µs making 2 calls to Class::MOP::_definition_context, avg 8µs/call
93 ));
94
95 # create some helper methods
96 $META->add_method($methods->{add} => sub {
97 my ($self, @values) = @_;
98 $self->$attr_reader->{$_} = undef foreach @values;
9924µs156µs }) if exists $methods->{add};
# spent 56µs making 1 call to Class::MOP::Mixin::HasMethods::add_method
100
101 $META->add_method($methods->{get_keys} => sub {
10244µs my ($self) = @_;
103429µs411µs keys %{$self->$attr_reader};
# spent 11µs making 4 calls to Moose::Meta::Role::get_excluded_roles_map, avg 3µs/call
10424µs140µs }) if exists $methods->{get_keys};
# spent 40µs making 1 call to Class::MOP::Mixin::HasMethods::add_method
105
106 $META->add_method($methods->{get_values} => sub {
10743µs my ($self) = @_;
108432µs415µs values %{$self->$attr_reader};
# spent 15µs making 4 calls to Moose::Meta::Role::get_required_methods_map, avg 4µs/call
10924µs140µs }) if exists $methods->{get_values};
# spent 40µs making 1 call to Class::MOP::Mixin::HasMethods::add_method
110
111 $META->add_method($methods->{get} => sub {
112 my ($self, $name) = @_;
113 $self->$attr_reader->{$name}
1142900ns }) if exists $methods->{get};
115
116 $META->add_method($methods->{existence} => sub {
11723µs my ($self, $name) = @_;
118214µs26µs exists $self->$attr_reader->{$name} ? 1 : 0;
# spent 6µs making 2 calls to Moose::Meta::Role::get_excluded_roles_map, avg 3µs/call
11929µs277µs }) if exists $methods->{existence};
# spent 77µs making 2 calls to Class::MOP::Mixin::HasMethods::add_method, avg 39µs/call
120
121 $META->add_method($methods->{remove} => sub {
122 my ($self, @values) = @_;
123 delete $self->$attr_reader->{$_} foreach @values;
12426µs139µs }) if exists $methods->{remove};
# spent 39µs making 1 call to Class::MOP::Mixin::HasMethods::add_method
125}
126
127$META->add_attribute(
12813µs2270µs 'method_metaclass',
# spent 265µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 5µs making 1 call to Class::MOP::_definition_context
129 reader => 'method_metaclass',
130 default => 'Moose::Meta::Role::Method',
131 Class::MOP::_definition_context(),
132);
133
13413µs2279µs$META->add_attribute(
# spent 274µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 5µs making 1 call to Class::MOP::_definition_context
135 'required_method_metaclass',
136 reader => 'required_method_metaclass',
137 default => 'Moose::Meta::Role::Method::Required',
138 Class::MOP::_definition_context(),
139);
140
14113µs2269µs$META->add_attribute(
# spent 264µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 4µs making 1 call to Class::MOP::_definition_context
142 'conflicting_method_metaclass',
143 reader => 'conflicting_method_metaclass',
144 default => 'Moose::Meta::Role::Method::Conflicting',
145 Class::MOP::_definition_context(),
146);
147
14813µs2267µs$META->add_attribute(
# spent 262µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 5µs making 1 call to Class::MOP::_definition_context
149 'application_to_class_class',
150 reader => 'application_to_class_class',
151 default => 'Moose::Meta::Role::Application::ToClass',
152 Class::MOP::_definition_context(),
153);
154
15513µs2265µs$META->add_attribute(
# spent 261µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 5µs making 1 call to Class::MOP::_definition_context
156 'application_to_role_class',
157 reader => 'application_to_role_class',
158 default => 'Moose::Meta::Role::Application::ToRole',
159 Class::MOP::_definition_context(),
160);
161
16213µs2268µs$META->add_attribute(
# spent 264µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 4µs making 1 call to Class::MOP::_definition_context
163 'application_to_instance_class',
164 reader => 'application_to_instance_class',
165 default => 'Moose::Meta::Role::Application::ToInstance',
166 Class::MOP::_definition_context(),
167);
168
16913µs2283µs$META->add_attribute(
# spent 278µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 4µs making 1 call to Class::MOP::_definition_context
170 'applied_attribute_metaclass',
171 reader => 'applied_attribute_metaclass',
172 default => 'Moose::Meta::Attribute',
173 Class::MOP::_definition_context(),
174);
175
176# More or less copied from Moose::Meta::Class
177
# spent 718µs (99+620) within Moose::Meta::Role::initialize which was called 4 times, avg 180µs/call: # 4 times (99µs+620µs) by Moose::Role::init_meta at line 137 of Moose/Role.pm, avg 180µs/call
sub initialize {
17842µs my $class = shift;
17945µs my @args = @_;
18048µs unshift @args, 'package' if @args % 2;
18149µs my %opts = @args;
18246µs my $package = delete $opts{package};
183463µs8620µs return Class::MOP::get_metaclass_by_name($package)
# spent 616µs making 4 calls to Class::MOP::Package::initialize, avg 154µs/call # spent 4µs making 4 calls to Class::MOP::get_metaclass_by_name, avg 1µs/call
184 || $class->SUPER::initialize($package,
185 'attribute_metaclass' => 'Moose::Meta::Role::Attribute',
186 %opts,
187 );
188}
189
190sub reinitialize {
191 my $self = shift;
192 my $pkg = shift;
193
194 my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg);
195
196 my %existing_classes;
197 if ($meta) {
198 %existing_classes = map { $_ => $meta->$_() } qw(
199 attribute_metaclass
200 method_metaclass
201 wrapped_method_metaclass
202 required_method_metaclass
203 conflicting_method_metaclass
204 application_to_class_class
205 application_to_role_class
206 application_to_instance_class
207 applied_attribute_metaclass
208 );
209 }
210
211 my %options = @_;
212 $options{weaken} = Class::MOP::metaclass_is_weak($meta->name)
213 if !exists $options{weaken}
214 && blessed($meta)
215 && $meta->isa('Moose::Meta::Role');
216
217 # don't need to remove generated metaobjects here yet, since we don't
218 # yet generate anything in roles. this may change in the future though...
219 # keep an eye on that
220 my $new_meta = $self->SUPER::reinitialize(
221 $pkg,
222 %existing_classes,
223 %options,
224 );
225 $new_meta->_restore_metaobjects_from($meta)
226 if $meta && $meta->isa('Moose::Meta::Role');
227 return $new_meta;
228}
229
230sub _restore_metaobjects_from {
231 my $self = shift;
232 my ($old_meta) = @_;
233
234 $self->_restore_metamethods_from($old_meta);
235 $self->_restore_metaattributes_from($old_meta);
236
237 for my $role ( @{ $old_meta->get_roles } ) {
238 $self->add_role($role);
239 }
240}
241
242
# spent 558µs (88+470) within Moose::Meta::Role::add_attribute which was called 2 times, avg 279µs/call: # 2 times (88µs+470µs) by Moose::Role::has at line 50 of Moose/Role.pm, avg 279µs/call
sub add_attribute {
24322µs my $self = shift;
244
245237µs610µs if (blessed $_[0] && ! $_[0]->isa('Moose::Meta::Role::Attribute') ) {
# spent 6µs making 2 calls to Moose::Meta::Role::CORE:match, avg 3µs/call # spent 4µs making 4 calls to Scalar::Util::blessed, avg 1µs/call
246 my $class = ref $_[0];
247 Moose->throw_error( "Cannot add a $class as an attribute to a role" );
248 }
249 elsif (!blessed($_[0]) && defined($_[0]) && $_[0] =~ /^\+(.*)/) {
250 Moose->throw_error( "has '+attr' is not supported in roles" );
251 }
252
253256µs2461µs return $self->SUPER::add_attribute(@_);
# spent 461µs making 2 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 230µs/call
254}
255
256
# spent 67µs (18+49) within Moose::Meta::Role::_attach_attribute which was called 2 times, avg 33µs/call: # 2 times (18µs+49µs) by Class::MOP::Mixin::HasAttributes::add_attribute at line 27 of Class/MOP/Mixin/HasAttributes.pm, avg 33µs/call
sub _attach_attribute {
25723µs my ( $self, $attribute ) = @_;
258
259215µs249µs $attribute->attach_to_role($self);
# spent 49µs making 2 calls to Moose::Meta::Role::Attribute::attach_to_role, avg 24µs/call
260}
261
262
# spent 238µs (75+164) within Moose::Meta::Role::add_required_methods which was called 2 times, avg 119µs/call: # 2 times (75µs+164µs) by Moose::Role::requires at line 35 of Moose/Role.pm, avg 119µs/call
sub add_required_methods {
2632900ns my $self = shift;
264
26527µs for (@_) {
26642µs my $method = $_;
267436µs12146µs if (!blessed($method)) {
# spent 133µs making 4 calls to Moose::Meta::Role::Method::Required::new, avg 33µs/call # spent 11µs making 4 calls to Moose::Meta::Role::required_method_metaclass, avg 3µs/call # spent 2µs making 4 calls to Scalar::Util::blessed, avg 550ns/call
268 $method = $self->required_method_metaclass->new(
269 name => $method,
270 );
271 }
272418µs818µs $self->get_required_methods_map->{$method->name} = $method;
# spent 10µs making 4 calls to Moose::Meta::Role::get_required_methods_map, avg 2µs/call # spent 8µs making 4 calls to Moose::Meta::Role::Method::Required::name, avg 2µs/call
273 }
274}
275
276sub add_conflicting_method {
277 my $self = shift;
278
279 my $method;
280 if (@_ == 1 && blessed($_[0])) {
281 $method = shift;
282 }
283 else {
284 $method = $self->conflicting_method_metaclass->new(@_);
285 }
286
287 $self->add_required_methods($method);
288}
289
290## ------------------------------------------------------------------
291## method modifiers
292
293# NOTE:
294# the before/around/after method modifiers are
295# stored by name, but there can be many methods
296# then associated with that name. So again we have
297# lots of similar functionality, so we can do some
298# meta-programmin' and save some time.
299# - SL
300
30111µsforeach my $modifier_type (qw[ before around after ]) {
302
30332µs my $attr_reader = "get_${modifier_type}_method_modifiers_map";
304
305 # create the attribute ...
306 $META->add_attribute("${modifier_type}_method_modifiers" => (
307 reader => $attr_reader,
3081231µs
# spent 22µs within Moose::Meta::Role::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Meta/Role.pm:308] which was called 12 times, avg 2µs/call: # 4 times (9µs+0s) by Moose::Meta::Role::_new at line 21 of (eval 189)[Eval/Closure.pm:125], avg 2µs/call # 4 times (7µs+0s) by Moose::Meta::Role::_new at line 72 of (eval 189)[Eval/Closure.pm:125], avg 2µs/call # 4 times (6µs+0s) by Moose::Meta::Role::_new at line 51 of (eval 189)[Eval/Closure.pm:125], avg 2µs/call
default => sub { {} },
309312µs6841µs Class::MOP::_definition_context(),
# spent 823µs making 3 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 274µs/call # spent 18µs making 3 calls to Class::MOP::_definition_context, avg 6µs/call
310 ));
311
312 # and some helper methods ...
313 $META->add_method("get_${modifier_type}_method_modifiers" => sub {
314 my ($self, $method_name) = @_;
315 #return () unless exists $self->$attr_reader->{$method_name};
316 my $mm = $self->$attr_reader->{$method_name};
317 $mm ? @$mm : ();
318310µs3120µs });
# spent 120µs making 3 calls to Class::MOP::Mixin::HasMethods::add_method, avg 40µs/call
319
320 $META->add_method("has_${modifier_type}_method_modifiers" => sub {
321 my ($self, $method_name) = @_;
322 # NOTE:
323 # for now we assume that if it exists,..
324 # it has at least one modifier in it
325 (exists $self->$attr_reader->{$method_name}) ? 1 : 0;
32639µs3116µs });
# spent 116µs making 3 calls to Class::MOP::Mixin::HasMethods::add_method, avg 39µs/call
327
328 $META->add_method("add_${modifier_type}_method_modifier" => sub {
329 my ($self, $method_name, $method) = @_;
330
331 $self->$attr_reader->{$method_name} = []
332 unless exists $self->$attr_reader->{$method_name};
333
334 my $modifiers = $self->$attr_reader->{$method_name};
335
336 # NOTE:
337 # check to see that we aren't adding the
338 # same code twice. We err in favor of the
339 # first on here, this may not be as expected
340 foreach my $modifier (@{$modifiers}) {
341 return if $modifier == $method;
342 }
343
344 push @{$modifiers} => $method;
345315µs3116µs });
# spent 116µs making 3 calls to Class::MOP::Mixin::HasMethods::add_method, avg 39µs/call
346
347}
348
349## ------------------------------------------------------------------
350## override method mofidiers
351
352$META->add_attribute('override_method_modifiers' => (
353 reader => 'get_override_method_modifiers_map',
354416µs
# spent 8µs within Moose::Meta::Role::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Meta/Role.pm:354] which was called 4 times, avg 2µs/call: # 4 times (8µs+0s) by Moose::Meta::Role::_new at line 99 of (eval 189)[Eval/Closure.pm:125], avg 2µs/call
default => sub { {} },
35514µs2276µs Class::MOP::_definition_context(),
# spent 272µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 5µs making 1 call to Class::MOP::_definition_context
356));
357
358# NOTE:
359# these are a little different because there
360# can only be one per name, whereas the other
361# method modifiers can have multiples.
362# - SL
363
364sub add_override_method_modifier {
365 my ($self, $method_name, $method) = @_;
366 (!$self->has_method($method_name))
367 || Moose->throw_error("Cannot add an override of method '$method_name' " .
368 "because there is a local version of '$method_name'");
369 $self->get_override_method_modifiers_map->{$method_name} = $method;
370}
371
372sub has_override_method_modifier {
373 my ($self, $method_name) = @_;
374 # NOTE:
375 # for now we assume that if it exists,..
376 # it has at least one modifier in it
377 (exists $self->get_override_method_modifiers_map->{$method_name}) ? 1 : 0;
378}
379
380sub get_override_method_modifier {
381 my ($self, $method_name) = @_;
382 $self->get_override_method_modifiers_map->{$method_name};
383}
384
385## general list accessor ...
386
387
# spent 216µs (160+56) within Moose::Meta::Role::get_method_modifier_list which was called 16 times, avg 14µs/call: # 12 times (110µs+42µs) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 227 of Moose/Meta/Role/Application/ToClass.pm, avg 13µs/call # 4 times (50µs+15µs) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 205 of Moose/Meta/Role/Application/ToClass.pm, avg 16µs/call
sub get_method_modifier_list {
3881610µs my ($self, $modifier_type) = @_;
3891614µs my $accessor = "get_${modifier_type}_method_modifiers_map";
39016136µs1656µs keys %{$self->$accessor};
# spent 15µs making 4 calls to Moose::Meta::Role::get_override_method_modifiers_map, avg 4µs/call # spent 14µs making 4 calls to Moose::Meta::Role::get_before_method_modifiers_map, avg 4µs/call # spent 14µs making 4 calls to Moose::Meta::Role::get_after_method_modifiers_map, avg 3µs/call # spent 14µs making 4 calls to Moose::Meta::Role::get_around_method_modifiers_map, avg 3µs/call
391}
392
393410µs
# spent 7µs within Moose::Meta::Role::_meta_method_class which was called 4 times, avg 2µs/call: # 4 times (7µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 33 of Class/MOP/Mixin/HasMethods.pm, avg 2µs/call
sub _meta_method_class { 'Moose::Meta::Method::Meta' }
394
395## ------------------------------------------------------------------
396## subroles
397
398$META->add_attribute('roles' => (
399 reader => 'get_roles',
400415µs
# spent 7µs within Moose::Meta::Role::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Meta/Role.pm:400] which was called 4 times, avg 2µs/call: # 4 times (7µs+0s) by Moose::Meta::Role::_new at line 120 of (eval 189)[Eval/Closure.pm:125], avg 2µs/call
default => sub { [] },
40114µs2278µs Class::MOP::_definition_context(),
# spent 273µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 5µs making 1 call to Class::MOP::_definition_context
402));
403
404sub add_role {
405 my ($self, $role) = @_;
406 (blessed($role) && $role->isa('Moose::Meta::Role'))
407 || Moose->throw_error("Roles must be instances of Moose::Meta::Role");
408 push @{$self->get_roles} => $role;
409 $self->reset_package_cache_flag;
410}
411
412sub calculate_all_roles {
413 my $self = shift;
414 my %seen;
415 grep {
416 !$seen{$_->name}++
417 } ($self, map {
418 $_->calculate_all_roles
419 } @{ $self->get_roles });
420}
421
422
# spent 67µs (57+10) within Moose::Meta::Role::does_role which was called 3 times, avg 22µs/call: # 3 times (57µs+10µs) by Moose::Meta::Class::does_role at line 245 of Moose/Meta/Class.pm, avg 22µs/call
sub does_role {
42336µs my ($self, $role) = @_;
42432µs (defined $role)
425 || Moose->throw_error("You must supply a role name to look for");
426323µs35µs my $role_name = blessed $role ? $role->name : $role;
# spent 5µs making 3 calls to Scalar::Util::blessed, avg 2µs/call
427 # if we are it,.. then return true
428345µs35µs return 1 if $role_name eq $self->name;
# spent 5µs making 3 calls to Class::MOP::Package::name, avg 2µs/call
429 # otherwise.. check our children
430 foreach my $role (@{$self->get_roles}) {
431 return 1 if $role->does_role($role_name);
432 }
433 return 0;
434}
435
436413µs475µs
# spent 93µs (18+75) within Moose::Meta::Role::find_method_by_name which was called 4 times, avg 23µs/call: # 4 times (18µs+75µs) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 28 of Class/MOP/Mixin/HasMethods.pm, avg 23µs/call
sub find_method_by_name { (shift)->get_method(@_) }
# spent 75µs making 4 calls to Class::MOP::Mixin::HasMethods::get_method, avg 19µs/call
437
438## ------------------------------------------------------------------
439## role construction
440## ------------------------------------------------------------------
441
442
# spent 16.1ms (200µs+15.9) within Moose::Meta::Role::apply which was called 4 times, avg 4.02ms/call: # 4 times (200µs+15.9ms) by Moose::Util::_apply_all_roles at line 160 of Moose/Util.pm, avg 4.02ms/call
sub apply {
44348µs my ($self, $other, %args) = @_;
444
445422µs46µs (blessed($other))
# spent 6µs making 4 calls to Scalar::Util::blessed, avg 1µs/call
446 || Moose->throw_error("You must pass in an blessed instance");
447
44842µs my $application_class;
449479µs1244µs if ($other->isa('Moose::Meta::Role')) {
# spent 26µs making 4 calls to Moose::Meta::Role::application_to_class_class, avg 6µs/call # spent 18µs making 8 calls to UNIVERSAL::isa, avg 2µs/call
450 $application_class = $self->application_to_role_class;
451 }
452 elsif ($other->isa('Moose::Meta::Class')) {
453 $application_class = $self->application_to_class_class;
454 }
455 else {
456 $application_class = $self->application_to_instance_class;
457 }
458
459411µs4266µs load_class($application_class);
# spent 266µs making 4 calls to Class::Load::load_class, avg 66µs/call
460
46144µs if ( exists $args{'-excludes'} ) {
462 # I wish we had coercion here :)
463 $args{'-excludes'} = (
464 ref $args{'-excludes'} eq 'ARRAY'
465 ? $args{'-excludes'}
466 : [ $args{'-excludes'} ]
467 );
468 }
469
470484µs815.6ms return $application_class->new(%args)->apply($self, $other, \%args);
# spent 15.3ms making 4 calls to Moose::Meta::Role::Application::ToClass::apply, avg 3.82ms/call # spent 256µs making 4 calls to Moose::Meta::Role::Application::new, avg 64µs/call
471}
472
473sub composition_class_roles { }
474
475sub combine {
476 my ($class, @role_specs) = @_;
477
478 require Moose::Meta::Role::Composite;
479
480 my (@roles, %role_params);
481 while (@role_specs) {
482 my ($role, $params) = @{ splice @role_specs, 0, 1 };
483 my $requested_role
484 = blessed $role
485 ? $role
486 : Class::MOP::class_of($role);
487
488 my $actual_role = $requested_role->_role_for_combination($params);
489 push @roles => $actual_role;
490
491 next unless defined $params;
492 $role_params{$actual_role->name} = $params;
493 }
494
495 my $c = Moose::Meta::Role::Composite->new(roles => \@roles);
496 return $c->apply_params(\%role_params);
497}
498
499sub _role_for_combination {
500 my ($self, $params) = @_;
501 return $self;
502}
503
504sub create {
505 my $class = shift;
506 my @args = @_;
507
508 unshift @args, 'package' if @args % 2 == 1;
509 my %options = @args;
510
511 (ref $options{attributes} eq 'HASH')
512 || confess "You must pass a HASH ref of attributes"
513 if exists $options{attributes};
514
515 (ref $options{methods} eq 'HASH')
516 || confess "You must pass a HASH ref of methods"
517 if exists $options{methods};
518
519 (ref $options{roles} eq 'ARRAY')
520 || confess "You must pass an ARRAY ref of roles"
521 if exists $options{roles};
522
523 my $package = delete $options{package};
524 my $roles = delete $options{roles};
525 my $attributes = delete $options{attributes};
526 my $methods = delete $options{methods};
527 my $meta_name = exists $options{meta_name}
528 ? delete $options{meta_name}
529 : 'meta';
530
531 my $meta = $class->SUPER::create($package => %options);
532
533 $meta->_add_meta_method($meta_name)
534 if defined $meta_name;
535
536 if (defined $attributes) {
537 foreach my $attribute_name (keys %{$attributes}) {
538 my $attr = $attributes->{$attribute_name};
539 $meta->add_attribute(
540 $attribute_name => blessed $attr ? $attr : %{$attr} );
541 }
542 }
543
544 if (defined $methods) {
545 foreach my $method_name (keys %{$methods}) {
546 $meta->add_method($method_name, $methods->{$method_name});
547 }
548 }
549
550 if ($roles) {
551 Moose::Util::apply_all_roles($meta, @$roles);
552 }
553
554 return $meta;
555}
556
557sub consumers {
558 my $self = shift;
559 my @consumers;
560 for my $meta (Class::MOP::get_all_metaclass_instances) {
561 next if $meta->name eq $self->name;
562 next unless $meta->isa('Moose::Meta::Class')
563 || $meta->isa('Moose::Meta::Role');
564 push @consumers, $meta->name
565 if $meta->does_role($self->name);
566 }
567 return @consumers;
568}
569
570# XXX: something more intelligent here?
571sub _anon_package_prefix { 'Moose::Meta::Role::__ANON__::SERIAL::' }
572
573sub create_anon_role { shift->create_anon(@_) }
574sub is_anon_role { shift->is_anon(@_) }
575
576sub _anon_cache_key {
577 my $class = shift;
578 my %options = @_;
579
580 # XXX fix this duplication (see MMC::_anon_cache_key
581 my $roles = Data::OptList::mkopt(($options{roles} || []), {
582 moniker => 'role',
583 val_test => sub { ref($_[0]) eq 'HASH' },
584 });
585
586 my @role_keys;
587 for my $role_spec (@$roles) {
588 my ($role, $params) = @$role_spec;
589 $params = { %$params };
590
591 my $key = blessed($role) ? $role->name : $role;
592
593 if ($params && %$params) {
594 my $alias = delete $params->{'-alias'}
595 || delete $params->{'alias'}
596 || {};
597 my $excludes = delete $params->{'-excludes'}
598 || delete $params->{'excludes'}
599 || [];
600 $excludes = [$excludes] unless ref($excludes) eq 'ARRAY';
601
602 if (%$params) {
603 warn "Roles with parameters cannot be cached. Consider "
604 . "applying the parameters before calling "
605 . "create_anon_class, or using 'weaken => 0' instead";
606 return;
607 }
608
609 my $alias_key = join('%',
610 map { $_ => $alias->{$_} } sort keys %$alias
611 );
612 my $excludes_key = join('%',
613 sort @$excludes
614 );
615 $key .= '<' . join('+', 'a', $alias_key, 'e', $excludes_key) . '>';
616 }
617
618 push @role_keys, $key;
619 }
620
621 # Makes something like Role|Role::1
622 return join('|', sort @role_keys);
623}
624
625#####################################################################
626## NOTE:
627## This is Moose::Meta::Role as defined by Moose (plus the use of
628## MooseX::AttributeHelpers module). It is here as a reference to
629## make it easier to see what is happening above with all the meta
630## programming. - SL
631#####################################################################
632#
633# has 'roles' => (
634# metaclass => 'Array',
635# reader => 'get_roles',
636# isa => 'ArrayRef[Moose::Meta::Role]',
637# default => sub { [] },
638# provides => {
639# 'push' => 'add_role',
640# }
641# );
642#
643# has 'excluded_roles_map' => (
644# metaclass => 'Hash',
645# reader => 'get_excluded_roles_map',
646# isa => 'HashRef[Str]',
647# provides => {
648# # Not exactly set, cause it sets multiple
649# 'set' => 'add_excluded_roles',
650# 'keys' => 'get_excluded_roles_list',
651# 'exists' => 'excludes_role',
652# }
653# );
654#
655# has 'required_methods' => (
656# metaclass => 'Hash',
657# reader => 'get_required_methods_map',
658# isa => 'HashRef[Moose::Meta::Role::Method::Required]',
659# provides => {
660# # not exactly set, or delete since it works for multiple
661# 'set' => 'add_required_methods',
662# 'delete' => 'remove_required_methods',
663# 'keys' => 'get_required_method_list',
664# 'exists' => 'requires_method',
665# }
666# );
667#
668# # the before, around and after modifiers are
669# # HASH keyed by method-name, with ARRAY of
670# # CODE refs to apply in that order
671#
672# has 'before_method_modifiers' => (
673# metaclass => 'Hash',
674# reader => 'get_before_method_modifiers_map',
675# isa => 'HashRef[ArrayRef[CodeRef]]',
676# provides => {
677# 'keys' => 'get_before_method_modifiers',
678# 'exists' => 'has_before_method_modifiers',
679# # This actually makes sure there is an
680# # ARRAY at the given key, and pushed onto
681# # it. It also checks for duplicates as well
682# # 'add' => 'add_before_method_modifier'
683# }
684# );
685#
686# has 'after_method_modifiers' => (
687# metaclass => 'Hash',
688# reader =>'get_after_method_modifiers_map',
689# isa => 'HashRef[ArrayRef[CodeRef]]',
690# provides => {
691# 'keys' => 'get_after_method_modifiers',
692# 'exists' => 'has_after_method_modifiers',
693# # This actually makes sure there is an
694# # ARRAY at the given key, and pushed onto
695# # it. It also checks for duplicates as well
696# # 'add' => 'add_after_method_modifier'
697# }
698# );
699#
700# has 'around_method_modifiers' => (
701# metaclass => 'Hash',
702# reader =>'get_around_method_modifiers_map',
703# isa => 'HashRef[ArrayRef[CodeRef]]',
704# provides => {
705# 'keys' => 'get_around_method_modifiers',
706# 'exists' => 'has_around_method_modifiers',
707# # This actually makes sure there is an
708# # ARRAY at the given key, and pushed onto
709# # it. It also checks for duplicates as well
710# # 'add' => 'add_around_method_modifier'
711# }
712# );
713#
714# # override is similar to the other modifiers
715# # except that it is not an ARRAY of code refs
716# # but instead just a single name->code mapping
717#
718# has 'override_method_modifiers' => (
719# metaclass => 'Hash',
720# reader =>'get_override_method_modifiers_map',
721# isa => 'HashRef[CodeRef]',
722# provides => {
723# 'keys' => 'get_override_method_modifier',
724# 'exists' => 'has_override_method_modifier',
725# 'add' => 'add_override_method_modifier', # checks for local method ..
726# }
727# );
728#
729#####################################################################
730
731
732144µs1;
733
734# ABSTRACT: The Moose Role metaclass
735
- -
738=pod
739
740=head1 NAME
741
742Moose::Meta::Role - The Moose Role metaclass
743
744=head1 VERSION
745
746version 2.0602
747
748=head1 DESCRIPTION
749
750This class is a subclass of L<Class::MOP::Module> that provides
751additional Moose-specific functionality.
752
753Its API looks a lot like L<Moose::Meta::Class>, but internally it
754implements many things differently. This may change in the future.
755
756=head1 INHERITANCE
757
758C<Moose::Meta::Role> is a subclass of L<Class::MOP::Module>.
759
760=head1 METHODS
761
762=head2 Construction
763
764=over 4
765
766=item B<< Moose::Meta::Role->initialize($role_name) >>
767
768This method creates a new role object with the provided name.
769
770=item B<< Moose::Meta::Role->combine( [ $role => { ... } ], [ $role ], ... ) >>
771
772This method accepts a list of array references. Each array reference
773should contain a role name or L<Moose::Meta::Role> object as its first element. The second element is
774an optional hash reference. The hash reference can contain C<-excludes>
775and C<-alias> keys to control how methods are composed from the role.
776
777The return value is a new L<Moose::Meta::Role::Composite> that
778represents the combined roles.
779
780=item B<< $metarole->composition_class_roles >>
781
782When combining multiple roles using C<combine>, this method is used to obtain a
783list of role names to be applied to the L<Moose::Meta::Role::Composite>
784instance returned by C<combine>. The default implementation returns an empty
785list. Extensions that need to hook into role combination may wrap this method
786to return additional role names.
787
788=item B<< Moose::Meta::Role->create($name, %options) >>
789
790This method is identical to the L<Moose::Meta::Class> C<create>
791method.
792
793=item B<< Moose::Meta::Role->create_anon_role >>
794
795This method is identical to the L<Moose::Meta::Class>
796C<create_anon_class> method.
797
798=item B<< $metarole->is_anon_role >>
799
800Returns true if the role is an anonymous role.
801
802=item B<< $metarole->consumers >>
803
804Returns a list of names of classes and roles which consume this role.
805
806=back
807
808=head2 Role application
809
810=over 4
811
812=item B<< $metarole->apply( $thing, @options ) >>
813
814This method applies a role to the given C<$thing>. That can be another
815L<Moose::Meta::Role>, object, a L<Moose::Meta::Class> object, or a
816(non-meta) object instance.
817
818The options are passed directly to the constructor for the appropriate
819L<Moose::Meta::Role::Application> subclass.
820
821Note that this will apply the role even if the C<$thing> in question already
822C<does> this role. L<Moose::Util/does_role> is a convenient wrapper for
823finding out if role application is necessary.
824
825=back
826
827=head2 Roles and other roles
828
829=over 4
830
831=item B<< $metarole->get_roles >>
832
833This returns an array reference of roles which this role does. This
834list may include duplicates.
835
836=item B<< $metarole->calculate_all_roles >>
837
838This returns a I<unique> list of all roles that this role does, and
839all the roles that its roles do.
840
841=item B<< $metarole->does_role($role) >>
842
843Given a role I<name> or L<Moose::Meta::Role> object, returns true if this role
844does the given role.
845
846=item B<< $metarole->add_role($role) >>
847
848Given a L<Moose::Meta::Role> object, this adds the role to the list of
849roles that the role does.
850
851=item B<< $metarole->get_excluded_roles_list >>
852
853Returns a list of role names which this role excludes.
854
855=item B<< $metarole->excludes_role($role_name) >>
856
857Given a role I<name>, returns true if this role excludes the named
858role.
859
860=item B<< $metarole->add_excluded_roles(@role_names) >>
861
862Given one or more role names, adds those roles to the list of excluded
863roles.
864
865=back
866
867=head2 Methods
868
869The methods for dealing with a role's methods are all identical in API
870and behavior to the same methods in L<Class::MOP::Class>.
871
872=over 4
873
874=item B<< $metarole->method_metaclass >>
875
876Returns the method metaclass name for the role. This defaults to
877L<Moose::Meta::Role::Method>.
878
879=item B<< $metarole->get_method($name) >>
880
881=item B<< $metarole->has_method($name) >>
882
883=item B<< $metarole->add_method( $name, $body ) >>
884
885=item B<< $metarole->get_method_list >>
886
887=item B<< $metarole->find_method_by_name($name) >>
888
889These methods are all identical to the methods of the same name in
890L<Class::MOP::Package>
891
892=back
893
894=head2 Attributes
895
896As with methods, the methods for dealing with a role's attribute are
897all identical in API and behavior to the same methods in
898L<Class::MOP::Class>.
899
900However, attributes stored in this class are I<not> stored as
901objects. Rather, the attribute definition is stored as a hash
902reference. When a role is composed into a class, this hash reference
903is passed directly to the metaclass's C<add_attribute> method.
904
905This is quite likely to change in the future.
906
907=over 4
908
909=item B<< $metarole->get_attribute($attribute_name) >>
910
911=item B<< $metarole->has_attribute($attribute_name) >>
912
913=item B<< $metarole->get_attribute_list >>
914
915=item B<< $metarole->add_attribute($name, %options) >>
916
917=item B<< $metarole->remove_attribute($attribute_name) >>
918
919=back
920
921=head2 Overload introspection and creation
922
923The methods for dealing with a role's overloads are all identical in API
924and behavior to the same methods in L<Class::MOP::Class>. Note that these are
925not particularly useful (yet), because overloads do not participate in role
926composition.
927
928=over 4
929
930=item B<< $metarole->is_overloaded >>
931
932=item B<< $metarole->get_overloaded_operator($op) >>
933
934=item B<< $metarole->has_overloaded_operator($op) >>
935
936=item B<< $metarole->get_overload_list >>
937
938=item B<< $metarole->get_all_overloaded_operators >>
939
940=item B<< $metarole->add_overloaded_operator($op, $impl) >>
941
942=item B<< $metarole->remove_overloaded_operator($op) >>
943
944=back
945
946=head2 Required methods
947
948=over 4
949
950=item B<< $metarole->get_required_method_list >>
951
952Returns the list of methods required by the role.
953
954=item B<< $metarole->requires_method($name) >>
955
956Returns true if the role requires the named method.
957
958=item B<< $metarole->add_required_methods(@names) >>
959
960Adds the named methods to the role's list of required methods.
961
962=item B<< $metarole->remove_required_methods(@names) >>
963
964Removes the named methods from the role's list of required methods.
965
966=item B<< $metarole->add_conflicting_method(%params) >>
967
968Instantiate the parameters as a L<Moose::Meta::Role::Method::Conflicting>
969object, then add it to the required method list.
970
971=back
972
973=head2 Method modifiers
974
975These methods act like their counterparts in L<Class::MOP::Class> and
976L<Moose::Meta::Class>.
977
978However, method modifiers are simply stored internally, and are not
979applied until the role itself is applied to a class.
980
981=over 4
982
983=item B<< $metarole->add_after_method_modifier($method_name, $method) >>
984
985=item B<< $metarole->add_around_method_modifier($method_name, $method) >>
986
987=item B<< $metarole->add_before_method_modifier($method_name, $method) >>
988
989=item B<< $metarole->add_override_method_modifier($method_name, $method) >>
990
991These methods all add an appropriate modifier to the internal list of
992modifiers.
993
994=item B<< $metarole->has_after_method_modifiers >>
995
996=item B<< $metarole->has_around_method_modifiers >>
997
998=item B<< $metarole->has_before_method_modifiers >>
999
1000=item B<< $metarole->has_override_method_modifier >>
1001
1002Return true if the role has any modifiers of the given type.
1003
1004=item B<< $metarole->get_after_method_modifiers($method_name) >>
1005
1006=item B<< $metarole->get_around_method_modifiers($method_name) >>
1007
1008=item B<< $metarole->get_before_method_modifiers($method_name) >>
1009
1010Given a method name, returns a list of the appropriate modifiers for
1011that method.
1012
1013=item B<< $metarole->get_override_method_modifier($method_name) >>
1014
1015Given a method name, returns the override method modifier for that
1016method, if it has one.
1017
1018=back
1019
1020=head2 Introspection
1021
1022=over 4
1023
1024=item B<< Moose::Meta::Role->meta >>
1025
1026This will return a L<Class::MOP::Class> instance for this class.
1027
1028=back
1029
1030=head1 BUGS
1031
1032See L<Moose/BUGS> for details on reporting bugs.
1033
1034=head1 AUTHOR
1035
1036Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details.
1037
1038=head1 COPYRIGHT AND LICENSE
1039
1040This software is copyright (c) 2012 by Infinity Interactive, Inc..
1041
1042This is free software; you can redistribute it and/or modify it under
1043the same terms as the Perl 5 programming language system itself.
1044
1045=cut
1046
1047
1048__END__