Profile of Moose/Meta/Role.pm

← 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:22: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
Statements | Executed 292 statements in 4.25ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 712µs | 3.17ms | Moose::Meta::Role::::BEGIN@19Moose::Meta::Role::BEGIN@19
1 | 1 | 1 | 286µs | 1.45ms | Moose::Meta::Role::::BEGIN@22Moose::Meta::Role::BEGIN@22
1 | 1 | 1 | 265µs | 1.59ms | Moose::Meta::Role::::BEGIN@21Moose::Meta::Role::BEGIN@21
1 | 1 | 1 | 254µs | 388µs | Moose::Meta::Role::::BEGIN@20Moose::Meta::Role::BEGIN@20
4 | 1 | 1 | 200µs | 16.1ms | Moose::Meta::Role::::applyMoose::Meta::Role::apply
16 | 2 | 1 | 160µs | 216µs | Moose::Meta::Role::::get_method_modifier_listMoose::Meta::Role::get_method_modifier_list
4 | 1 | 1 | 99µs | 718µs | Moose::Meta::Role::::initializeMoose::Meta::Role::initialize
2 | 1 | 1 | 88µs | 558µs | Moose::Meta::Role::::add_attributeMoose::Meta::Role::add_attribute
2 | 1 | 1 | 75µs | 238µs | Moose::Meta::Role::::add_required_methodsMoose::Meta::Role::add_required_methods
3 | 1 | 1 | 57µs | 67µs | Moose::Meta::Role::::does_roleMoose::Meta::Role::does_role
12 | 3 | 1 | 22µs | 22µs | Moose::Meta::Role::::__ANON__[:308]Moose::Meta::Role::__ANON__[:308]
4 | 1 | 1 | 18µs | 93µs | Moose::Meta::Role::::find_method_by_nameMoose::Meta::Role::find_method_by_name
2 | 1 | 1 | 18µs | 67µs | Moose::Meta::Role::::_attach_attributeMoose::Meta::Role::_attach_attribute
8 | 2 | 1 | 13µs | 13µs | Moose::Meta::Role::::__ANON__[:91]Moose::Meta::Role::__ANON__[:91]
1 | 1 | 1 | 10µs | 226µs | Moose::Meta::Role::::BEGIN@16Moose::Meta::Role::BEGIN@16
1 | 1 | 1 | 10µs | 49µs | Moose::Meta::Role::::BEGIN@13Moose::Meta::Role::BEGIN@13
1 | 1 | 1 | 9µs | 9µs | Moose::Meta::Role::::BEGIN@2Moose::Meta::Role::BEGIN@2
1 | 1 | 1 | 8µs | 174µs | Moose::Meta::Role::::BEGIN@27Moose::Meta::Role::BEGIN@27
1 | 1 | 1 | 8µs | 26µs | Moose::Meta::Role::::BEGIN@10Moose::Meta::Role::BEGIN@10
4 | 1 | 1 | 8µs | 8µs | Moose::Meta::Role::::__ANON__[:354]Moose::Meta::Role::__ANON__[:354]
1 | 1 | 1 | 8µs | 590µs | Moose::Meta::Role::::BEGIN@11Moose::Meta::Role::BEGIN@11
1 | 1 | 1 | 8µs | 205µs | Moose::Meta::Role::::BEGIN@24Moose::Meta::Role::BEGIN@24
4 | 1 | 1 | 7µs | 7µs | Moose::Meta::Role::::_meta_method_classMoose::Meta::Role::_meta_method_class
1 | 1 | 1 | 7µs | 10µs | Moose::Meta::Role::::BEGIN@9Moose::Meta::Role::BEGIN@9
1 | 1 | 1 | 7µs | 28µs | Moose::Meta::Role::::BEGIN@15Moose::Meta::Role::BEGIN@15
1 | 1 | 1 | 7µs | 7µs | Moose::Meta::Role::::BEGIN@23Moose::Meta::Role::BEGIN@23
1 | 1 | 1 | 7µs | 35µs | Moose::Meta::Role::::BEGIN@14Moose::Meta::Role::BEGIN@14
4 | 1 | 1 | 7µs | 7µs | Moose::Meta::Role::::__ANON__[:400]Moose::Meta::Role::__ANON__[:400]
1 | 1 | 1 | 5µs | 5µs | Moose::Meta::Role::::BEGIN@18Moose::Meta::Role::BEGIN@18
1 | 1 | 1 | 5µs | 5µs | Moose::Meta::Role::::BEGIN@25Moose::Meta::Role::BEGIN@25
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::__ANON__[:104]Moose::Meta::Role::__ANON__[:104]
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::__ANON__[:109]Moose::Meta::Role::__ANON__[:109]
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::__ANON__[:114]Moose::Meta::Role::__ANON__[:114]
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::__ANON__[:119]Moose::Meta::Role::__ANON__[:119]
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::__ANON__[:124]Moose::Meta::Role::__ANON__[:124]
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::__ANON__[:318]Moose::Meta::Role::__ANON__[:318]
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::__ANON__[:326]Moose::Meta::Role::__ANON__[:326]
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::__ANON__[:345]Moose::Meta::Role::__ANON__[:345]
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::__ANON__[:583]Moose::Meta::Role::__ANON__[:583]
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::__ANON__[:99]Moose::Meta::Role::__ANON__[:99]
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::_anon_cache_keyMoose::Meta::Role::_anon_cache_key
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::_anon_package_prefixMoose::Meta::Role::_anon_package_prefix
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::_restore_metaobjects_fromMoose::Meta::Role::_restore_metaobjects_from
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::_role_for_combinationMoose::Meta::Role::_role_for_combination
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::add_conflicting_methodMoose::Meta::Role::add_conflicting_method
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::add_override_method_modifierMoose::Meta::Role::add_override_method_modifier
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::add_roleMoose::Meta::Role::add_role
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::calculate_all_rolesMoose::Meta::Role::calculate_all_roles
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::combineMoose::Meta::Role::combine
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::composition_class_rolesMoose::Meta::Role::composition_class_roles
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::consumersMoose::Meta::Role::consumers
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::createMoose::Meta::Role::create
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::create_anon_roleMoose::Meta::Role::create_anon_role
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::get_override_method_modifierMoose::Meta::Role::get_override_method_modifier
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::has_override_method_modifierMoose::Meta::Role::has_override_method_modifier
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::::is_anon_roleMoose::Meta::Role::is_anon_role
0 | 0 | 0 | 0s | 0s | Moose::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
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package 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 {
3 | 1 | 4µs |  |  | $Moose::Meta::Role::AUTHORITY = 'cpan:STEVAN';
4 | 1 | 26µs | 1 | 9µs | } # spent 9µs making 1 call to Moose::Meta::Role::BEGIN@2
5 |  |  |  |  | {
6 | 2 | 2µs |  |  | $Moose::Meta::Role::VERSION = '2.0602';
7 |  |  |  |  | }
8 |  |  |  |  |
9 | 3 | 17µs | 2 | 14µ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
10 | 3 | 18µs | 2 | 44µ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
11 | 3 | 30µs | 2 | 1.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 |  |  |  |  |
13 | 3 | 22µs | 2 | 89µ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
14 | 3 | 18µs | 2 | 63µ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
15 | 3 | 18µs | 2 | 48µ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
16 | 3 | 22µs | 2 | 443µ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 |  |  |  |  |
18 | 3 | 18µs | 1 | 5µ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
19 | 3 | 160µs | 1 | 3.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
20 | 3 | 134µs | 1 | 388µ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
21 | 3 | 89µs | 1 | 1.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
22 | 3 | 135µs | 1 | 1.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
23 | 3 | 23µs | 1 | 7µ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
24 | 3 | 21µs | 2 | 403µ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]
25 | 3 | 24µs | 1 | 5µ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 |  |  |  |  |
27 |  |  | 1 | 166µ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',
29 | 3 | 2.38ms | 1 | 174µs | 'Class::MOP::Mixin::HasMethods'; # spent 174µs making 1 call to Moose::Meta::Role::BEGIN@27
30 |  |  |  |  |
31 | 1 | 7µs | 1 | 1.32ms | Class::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 |  |  |  |  |
45 | 1 | 3µs | 1 | 15µs | my $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 |  |  |  |  |
64 | 1 | 10µs |  |  | foreach 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 |  |  |  |  |
85 | 2 | 1µs |  |  | my $attr_reader = $action->{attr_reader};
86 | 2 | 900ns |  |  | my $methods = $action->{methods};
87 |  |  |  |  |
88 |  |  |  |  | # create the attribute
89 |  |  |  |  | $META->add_attribute($action->{name} => (
90 |  |  |  |  | reader => $attr_reader,
91 | 8 | 20µ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 { {} },
92 | 2 | 10µs | 4 | 717µ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;
99 | 2 | 4µs | 1 | 56µ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 {
102 | 8 | 33µs |  |  | my ($self) = @_;
103 |  |  | 4 | 11µs | keys %{$self->$attr_reader}; # spent 11µs making 4 calls to Moose::Meta::Role::get_excluded_roles_map, avg 3µs/call
104 | 2 | 4µs | 1 | 40µ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 {
107 | 8 | 35µs |  |  | my ($self) = @_;
108 |  |  | 4 | 15µs | values %{$self->$attr_reader}; # spent 15µs making 4 calls to Moose::Meta::Role::get_required_methods_map, avg 4µs/call
109 | 2 | 4µs | 1 | 40µ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}
114 | 2 | 900ns |  |  | }) if exists $methods->{get};
115 |  |  |  |  |
116 |  |  |  |  | $META->add_method($methods->{existence} => sub {
117 | 4 | 16µs |  |  | my ($self, $name) = @_;
118 |  |  | 2 | 6µ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
119 | 2 | 9µs | 2 | 77µ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;
124 | 2 | 6µs | 1 | 39µs | }) if exists $methods->{remove}; # spent 39µs making 1 call to Class::MOP::Mixin::HasMethods::add_method
125 |  |  |  |  | }
126 |  |  |  |  |
127 |  |  |  |  | $META->add_attribute(
128 | 1 | 3µs | 2 | 270µ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 |  |  |  |  |
134 | 1 | 3µs | 2 | 279µ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 |  |  |  |  |
141 | 1 | 3µs | 2 | 269µ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 |  |  |  |  |
148 | 1 | 3µs | 2 | 267µ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 |  |  |  |  |
155 | 1 | 3µs | 2 | 265µ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 |  |  |  |  |
162 | 1 | 3µs | 2 | 268µ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 |  |  |  |  |
169 | 1 | 3µs | 2 | 283µ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 {
178 | 24 | 92µs |  |  | my $class = shift;
179 |  |  |  |  | my @args = @_;
180 |  |  |  |  | unshift @args, 'package' if @args % 2;
181 |  |  |  |  | my %opts = @args;
182 |  |  |  |  | my $package = delete $opts{package};
183 |  |  | 8 | 620µ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 |  |  |  |  |
190 |  |  |  |  | sub 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 |  |  |  |  |
230 |  |  |  |  | sub _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 {
243 | 6 | 95µs |  |  | my $self = shift;
244 |  |  |  |  |
245 |  |  | 6 | 10µ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 |  |  |  |  |
253 |  |  | 2 | 461µ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 {
257 | 4 | 18µs |  |  | my ( $self, $attribute ) = @_;
258 |  |  |  |  |
259 |  |  | 2 | 49µ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 {
263 | 16 | 64µs |  |  | my $self = shift;
264 |  |  |  |  |
265 |  |  |  |  | for (@_) {
266 |  |  |  |  | my $method = $_;
267 |  |  | 12 | 146µ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 |  |  |  |  | }
272 |  |  | 8 | 18µ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 |  |  |  |  |
276 |  |  |  |  | sub 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 |  |  |  |  |
301 | 1 | 1µs |  |  | foreach my $modifier_type (qw[ before around after ]) {
302 |  |  |  |  |
303 | 3 | 2µ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,
308 | 12 | 31µ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 { {} },
309 | 3 | 12µs | 6 | 841µ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 : ();
318 | 3 | 10µs | 3 | 120µ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;
326 | 3 | 9µs | 3 | 116µ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;
345 | 3 | 15µs | 3 | 116µ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',
354 | 4 | 16µ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 { {} },
355 | 1 | 4µs | 2 | 276µ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 |  |  |  |  |
364 |  |  |  |  | sub 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 |  |  |  |  |
372 |  |  |  |  | sub 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 |  |  |  |  |
380 |  |  |  |  | sub 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 {
388 | 48 | 160µs |  |  | my ($self, $modifier_type) = @_;
389 |  |  |  |  | my $accessor = "get_${modifier_type}_method_modifiers_map";
390 |  |  | 16 | 56µ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 |  |  |  |  |
393 | 4 | 10µ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',
400 | 4 | 15µ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 { [] },
401 | 1 | 4µs | 2 | 278µ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 |  |  |  |  |
404 |  |  |  |  | sub 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 |  |  |  |  |
412 |  |  |  |  | sub 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 {
423 | 12 | 76µs |  |  | my ($self, $role) = @_;
424 |  |  |  |  | (defined $role)
425 |  |  |  |  | || Moose->throw_error("You must supply a role name to look for");
426 |  |  | 3 | 5µ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
428 |  |  | 3 | 5µ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 |  |  |  |  |
436 | 4 | 13µs | 4 | 75µ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 {
443 | 28 | 210µs |  |  | my ($self, $other, %args) = @_;
444 |  |  |  |  |
445 |  |  | 4 | 6µ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 |  |  |  |  |
448 |  |  |  |  | my $application_class;
449 |  |  | 12 | 44µ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 |  |  |  |  |
459 |  |  | 4 | 266µs | load_class($application_class); # spent 266µs making 4 calls to Class::Load::load_class, avg 66µs/call
460 |  |  |  |  |
461 |  |  |  |  | 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 |  |  |  |  |
470 |  |  | 8 | 15.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 |  |  |  |  |
473 |  |  |  |  | sub composition_class_roles { }
474 |  |  |  |  |
475 |  |  |  |  | sub 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 |  |  |  |  |
499 |  |  |  |  | sub _role_for_combination {
500 |  |  |  |  | my ($self, $params) = @_;
501 |  |  |  |  | return $self;
502 |  |  |  |  | }
503 |  |  |  |  |
504 |  |  |  |  | sub 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 |  |  |  |  |
557 |  |  |  |  | sub 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?
571 |  |  |  |  | sub _anon_package_prefix { 'Moose::Meta::Role::__ANON__::SERIAL::' }
572 |  |  |  |  |
573 |  |  |  |  | sub create_anon_role { shift->create_anon(@_) }
574 |  |  |  |  | sub is_anon_role { shift->is_anon(@_) }
575 |  |  |  |  |
576 |  |  |  |  | sub _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 |  |  |  |  |
732 | 1 | 44µs |  |  | 1;
733 |  |  |  |  |
734 |  |  |  |  | # ABSTRACT: The Moose Role metaclass
735 |  |  |  |  |
- - |  |  |  |  |
738 |  |  |  |  | =pod
739 |  |  |  |  |
740 |  |  |  |  | =head1 NAME
741 |  |  |  |  |
742 |  |  |  |  | Moose::Meta::Role - The Moose Role metaclass
743 |  |  |  |  |
744 |  |  |  |  | =head1 VERSION
745 |  |  |  |  |
746 |  |  |  |  | version 2.0602
747 |  |  |  |  |
748 |  |  |  |  | =head1 DESCRIPTION
749 |  |  |  |  |
750 |  |  |  |  | This class is a subclass of L<Class::MOP::Module> that provides
751 |  |  |  |  | additional Moose-specific functionality.
752 |  |  |  |  |
753 |  |  |  |  | Its API looks a lot like L<Moose::Meta::Class>, but internally it
754 |  |  |  |  | implements many things differently. This may change in the future.
755 |  |  |  |  |
756 |  |  |  |  | =head1 INHERITANCE
757 |  |  |  |  |
758 |  |  |  |  | C<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 |  |  |  |  |
768 |  |  |  |  | This method creates a new role object with the provided name.
769 |  |  |  |  |
770 |  |  |  |  | =item B<< Moose::Meta::Role->combine( [ $role => { ... } ], [ $role ], ... ) >>
771 |  |  |  |  |
772 |  |  |  |  | This method accepts a list of array references. Each array reference
773 |  |  |  |  | should contain a role name or L<Moose::Meta::Role> object as its first element. The second element is
774 |  |  |  |  | an optional hash reference. The hash reference can contain C<-excludes>
775 |  |  |  |  | and C<-alias> keys to control how methods are composed from the role.
776 |  |  |  |  |
777 |  |  |  |  | The return value is a new L<Moose::Meta::Role::Composite> that
778 |  |  |  |  | represents the combined roles.
779 |  |  |  |  |
780 |  |  |  |  | =item B<< $metarole->composition_class_roles >>
781 |  |  |  |  |
782 |  |  |  |  | When combining multiple roles using C<combine>, this method is used to obtain a
783 |  |  |  |  | list of role names to be applied to the L<Moose::Meta::Role::Composite>
784 |  |  |  |  | instance returned by C<combine>. The default implementation returns an empty
785 |  |  |  |  | list. Extensions that need to hook into role combination may wrap this method
786 |  |  |  |  | to return additional role names.
787 |  |  |  |  |
788 |  |  |  |  | =item B<< Moose::Meta::Role->create($name, %options) >>
789 |  |  |  |  |
790 |  |  |  |  | This method is identical to the L<Moose::Meta::Class> C<create>
791 |  |  |  |  | method.
792 |  |  |  |  |
793 |  |  |  |  | =item B<< Moose::Meta::Role->create_anon_role >>
794 |  |  |  |  |
795 |  |  |  |  | This method is identical to the L<Moose::Meta::Class>
796 |  |  |  |  | C<create_anon_class> method.
797 |  |  |  |  |
798 |  |  |  |  | =item B<< $metarole->is_anon_role >>
799 |  |  |  |  |
800 |  |  |  |  | Returns true if the role is an anonymous role.
801 |  |  |  |  |
802 |  |  |  |  | =item B<< $metarole->consumers >>
803 |  |  |  |  |
804 |  |  |  |  | Returns 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 |  |  |  |  |
814 |  |  |  |  | This method applies a role to the given C<$thing>. That can be another
815 |  |  |  |  | L<Moose::Meta::Role>, object, a L<Moose::Meta::Class> object, or a
816 |  |  |  |  | (non-meta) object instance.
817 |  |  |  |  |
818 |  |  |  |  | The options are passed directly to the constructor for the appropriate
819 |  |  |  |  | L<Moose::Meta::Role::Application> subclass.
820 |  |  |  |  |
821 |  |  |  |  | Note that this will apply the role even if the C<$thing> in question already
822 |  |  |  |  | C<does> this role. L<Moose::Util/does_role> is a convenient wrapper for
823 |  |  |  |  | finding 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 |  |  |  |  |
833 |  |  |  |  | This returns an array reference of roles which this role does. This
834 |  |  |  |  | list may include duplicates.
835 |  |  |  |  |
836 |  |  |  |  | =item B<< $metarole->calculate_all_roles >>
837 |  |  |  |  |
838 |  |  |  |  | This returns a I<unique> list of all roles that this role does, and
839 |  |  |  |  | all the roles that its roles do.
840 |  |  |  |  |
841 |  |  |  |  | =item B<< $metarole->does_role($role) >>
842 |  |  |  |  |
843 |  |  |  |  | Given a role I<name> or L<Moose::Meta::Role> object, returns true if this role
844 |  |  |  |  | does the given role.
845 |  |  |  |  |
846 |  |  |  |  | =item B<< $metarole->add_role($role) >>
847 |  |  |  |  |
848 |  |  |  |  | Given a L<Moose::Meta::Role> object, this adds the role to the list of
849 |  |  |  |  | roles that the role does.
850 |  |  |  |  |
851 |  |  |  |  | =item B<< $metarole->get_excluded_roles_list >>
852 |  |  |  |  |
853 |  |  |  |  | Returns a list of role names which this role excludes.
854 |  |  |  |  |
855 |  |  |  |  | =item B<< $metarole->excludes_role($role_name) >>
856 |  |  |  |  |
857 |  |  |  |  | Given a role I<name>, returns true if this role excludes the named
858 |  |  |  |  | role.
859 |  |  |  |  |
860 |  |  |  |  | =item B<< $metarole->add_excluded_roles(@role_names) >>
861 |  |  |  |  |
862 |  |  |  |  | Given one or more role names, adds those roles to the list of excluded
863 |  |  |  |  | roles.
864 |  |  |  |  |
865 |  |  |  |  | =back
866 |  |  |  |  |
867 |  |  |  |  | =head2 Methods
868 |  |  |  |  |
869 |  |  |  |  | The methods for dealing with a role's methods are all identical in API
870 |  |  |  |  | and behavior to the same methods in L<Class::MOP::Class>.
871 |  |  |  |  |
872 |  |  |  |  | =over 4
873 |  |  |  |  |
874 |  |  |  |  | =item B<< $metarole->method_metaclass >>
875 |  |  |  |  |
876 |  |  |  |  | Returns the method metaclass name for the role. This defaults to
877 |  |  |  |  | L<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 |  |  |  |  |
889 |  |  |  |  | These methods are all identical to the methods of the same name in
890 |  |  |  |  | L<Class::MOP::Package>
891 |  |  |  |  |
892 |  |  |  |  | =back
893 |  |  |  |  |
894 |  |  |  |  | =head2 Attributes
895 |  |  |  |  |
896 |  |  |  |  | As with methods, the methods for dealing with a role's attribute are
897 |  |  |  |  | all identical in API and behavior to the same methods in
898 |  |  |  |  | L<Class::MOP::Class>.
899 |  |  |  |  |
900 |  |  |  |  | However, attributes stored in this class are I<not> stored as
901 |  |  |  |  | objects. Rather, the attribute definition is stored as a hash
902 |  |  |  |  | reference. When a role is composed into a class, this hash reference
903 |  |  |  |  | is passed directly to the metaclass's C<add_attribute> method.
904 |  |  |  |  |
905 |  |  |  |  | This 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 |  |  |  |  |
923 |  |  |  |  | The methods for dealing with a role's overloads are all identical in API
924 |  |  |  |  | and behavior to the same methods in L<Class::MOP::Class>. Note that these are
925 |  |  |  |  | not particularly useful (yet), because overloads do not participate in role
926 |  |  |  |  | composition.
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 |  |  |  |  |
952 |  |  |  |  | Returns the list of methods required by the role.
953 |  |  |  |  |
954 |  |  |  |  | =item B<< $metarole->requires_method($name) >>
955 |  |  |  |  |
956 |  |  |  |  | Returns true if the role requires the named method.
957 |  |  |  |  |
958 |  |  |  |  | =item B<< $metarole->add_required_methods(@names) >>
959 |  |  |  |  |
960 |  |  |  |  | Adds the named methods to the role's list of required methods.
961 |  |  |  |  |
962 |  |  |  |  | =item B<< $metarole->remove_required_methods(@names) >>
963 |  |  |  |  |
964 |  |  |  |  | Removes the named methods from the role's list of required methods.
965 |  |  |  |  |
966 |  |  |  |  | =item B<< $metarole->add_conflicting_method(%params) >>
967 |  |  |  |  |
968 |  |  |  |  | Instantiate the parameters as a L<Moose::Meta::Role::Method::Conflicting>
969 |  |  |  |  | object, then add it to the required method list.
970 |  |  |  |  |
971 |  |  |  |  | =back
972 |  |  |  |  |
973 |  |  |  |  | =head2 Method modifiers
974 |  |  |  |  |
975 |  |  |  |  | These methods act like their counterparts in L<Class::MOP::Class> and
976 |  |  |  |  | L<Moose::Meta::Class>.
977 |  |  |  |  |
978 |  |  |  |  | However, method modifiers are simply stored internally, and are not
979 |  |  |  |  | applied 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 |  |  |  |  |
991 |  |  |  |  | These methods all add an appropriate modifier to the internal list of
992 |  |  |  |  | modifiers.
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 |  |  |  |  |
1002 |  |  |  |  | Return 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 |  |  |  |  |
1010 |  |  |  |  | Given a method name, returns a list of the appropriate modifiers for
1011 |  |  |  |  | that method.
1012 |  |  |  |  |
1013 |  |  |  |  | =item B<< $metarole->get_override_method_modifier($method_name) >>
1014 |  |  |  |  |
1015 |  |  |  |  | Given a method name, returns the override method modifier for that
1016 |  |  |  |  | method, if it has one.
1017 |  |  |  |  |
1018 |  |  |  |  | =back
1019 |  |  |  |  |
1020 |  |  |  |  | =head2 Introspection
1021 |  |  |  |  |
1022 |  |  |  |  | =over 4
1023 |  |  |  |  |
1024 |  |  |  |  | =item B<< Moose::Meta::Role->meta >>
1025 |  |  |  |  |
1026 |  |  |  |  | This will return a L<Class::MOP::Class> instance for this class.
1027 |  |  |  |  |
1028 |  |  |  |  | =back
1029 |  |  |  |  |
1030 |  |  |  |  | =head1 BUGS
1031 |  |  |  |  |
1032 |  |  |  |  | See L<Moose/BUGS> for details on reporting bugs.
1033 |  |  |  |  |
1034 |  |  |  |  | =head1 AUTHOR
1035 |  |  |  |  |
1036 |  |  |  |  | Moose 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 |  |  |  |  |
1040 |  |  |  |  | This software is copyright (c) 2012 by Infinity Interactive, Inc..
1041 |  |  |  |  |
1042 |  |  |  |  | This is free software; you can redistribute it and/or modify it under
1043 |  |  |  |  | the same terms as the Perl 5 programming language system itself.
1044 |  |  |  |  |
1045 |  |  |  |  | =cut
1046 |  |  |  |  |
1047 |  |  |  |  |
1048 |  |  |  |  | __END__