Profile of /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Meta/Role/Application/RoleSummation.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For 05.Domain_and_Item.t
Run on Tue May 4 17:21:41 2010
Reported on Tue May 4 17:22:40 2010

File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Meta/Role/Application/RoleSummation.pm
Statements Executed | 23
Statement Execution Time | 1.14ms

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 15µs | 18µs | Moose::Meta::Role::Application::RoleSummation::::BEGIN@3Moose::Meta::Role::Application::RoleSummation::BEGIN@3
1 | 1 | 1 | 8µs | 17µs | Moose::Meta::Role::Application::RoleSummation::::BEGIN@4Moose::Meta::Role::Application::RoleSummation::BEGIN@4
1 | 1 | 1 | 7µs | 54µs | Moose::Meta::Role::Application::RoleSummation::::BEGIN@15Moose::Meta::Role::Application::RoleSummation::BEGIN@15
1 | 1 | 1 | 7µs | 31µs | Moose::Meta::Role::Application::RoleSummation::::BEGIN@7Moose::Meta::Role::Application::RoleSummation::BEGIN@7
1 | 1 | 1 | 6µs | 101µs | Moose::Meta::Role::Application::RoleSummation::::BEGIN@5Moose::Meta::Role::Application::RoleSummation::BEGIN@5
1 | 1 | 1 | 4µs | 4µs | Moose::Meta::Role::Application::RoleSummation::::BEGIN@9Moose::Meta::Role::Application::RoleSummation::BEGIN@9
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Application::RoleSummation::::__ANON__[:19]Moose::Meta::Role::Application::RoleSummation::__ANON__[:19]
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Application::RoleSummation::::apply_attributesMoose::Meta::Role::Application::RoleSummation::apply_attributes
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Application::RoleSummation::::apply_method_modifiersMoose::Meta::Role::Application::RoleSummation::apply_method_modifiers
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Application::RoleSummation::::apply_methodsMoose::Meta::Role::Application::RoleSummation::apply_methods
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Application::RoleSummation::::apply_override_method_modifiersMoose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Application::RoleSummation::::check_required_attributesMoose::Meta::Role::Application::RoleSummation::check_required_attributes
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Application::RoleSummation::::check_required_methodsMoose::Meta::Role::Application::RoleSummation::check_required_methods
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Application::RoleSummation::::check_role_exclusionsMoose::Meta::Role::Application::RoleSummation::check_role_exclusions
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Application::RoleSummation::::get_exclusions_for_roleMoose::Meta::Role::Application::RoleSummation::get_exclusions_for_role
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Application::RoleSummation::::get_method_aliases_for_roleMoose::Meta::Role::Application::RoleSummation::get_method_aliases_for_role
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Application::RoleSummation::::is_aliased_methodMoose::Meta::Role::Application::RoleSummation::is_aliased_method
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Application::RoleSummation::::is_method_aliasedMoose::Meta::Role::Application::RoleSummation::is_method_aliased
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Application::RoleSummation::::is_method_excludedMoose::Meta::Role::Application::RoleSummation::is_method_excluded

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::Application::RoleSummation;
2 |  |  |  |  |
3 | 3 | 22µs | 2 | 20µs | # spent 18µs (15+3) within Moose::Meta::Role::Application::RoleSummation::BEGIN@3 which was called # once (15µs+3µs) by Moose::BEGIN@29 at line 3 use strict; # spent 18µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@3 # spent 3µs making 1 call to strict::import
4 | 3 | 19µs | 2 | 26µs | # spent 17µs (8+9) within Moose::Meta::Role::Application::RoleSummation::BEGIN@4 which was called # once (8µs+9µs) by Moose::BEGIN@29 at line 4 use warnings; # spent 17µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@4 # spent 9µs making 1 call to warnings::import
5 | 3 | 26µs | 2 | 195µs | # spent 101µs (6+94) within Moose::Meta::Role::Application::RoleSummation::BEGIN@5 which was called # once (6µs+94µs) by Moose::BEGIN@29 at line 5 use metaclass; # spent 101µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@5 # spent 94µs making 1 call to metaclass::import
6 |  |  |  |  |
7 | 3 | 23µs | 2 | 55µs | # spent 31µs (7+24) within Moose::Meta::Role::Application::RoleSummation::BEGIN@7 which was called # once (7µs+24µs) by Moose::BEGIN@29 at line 7 use Scalar::Util 'blessed'; # spent 31µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@7 # spent 24µs making 1 call to Exporter::import
8 |  |  |  |  |
9 | 3 | 48µs | 1 | 4µs | # spent 4µs within Moose::Meta::Role::Application::RoleSummation::BEGIN@9 which was called # once (4µs+0s) by Moose::BEGIN@29 at line 9 use Moose::Meta::Role::Composite; # spent 4µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@9
10 |  |  |  |  |
11 | 1 | 700ns |  |  | our $VERSION = '0.98';
12 | 1 | 20µs |  |  | $VERSION = eval $VERSION;
13 | 1 | 400ns |  |  | our $AUTHORITY = 'cpan:STEVAN';
14 |  |  |  |  |
15 | 3 | 972µs | 2 | 100µs | # spent 54µs (7+47) within Moose::Meta::Role::Application::RoleSummation::BEGIN@15 which was called # once (7µs+47µs) by Moose::BEGIN@29 at line 15 use base 'Moose::Meta::Role::Application'; # spent 54µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@15 # spent 47µs making 1 call to base::import
16 |  |  |  |  |
17 |  |  |  |  | __PACKAGE__->meta->add_attribute('role_params' => (
18 |  |  |  |  | reader => 'role_params',
19 |  |  |  |  | default => sub { {} }
20 | 1 | 5µs | 2 | 305µs | )); # spent 287µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 18µs making 1 call to Moose::Meta::Role::Application::RoleSummation::meta
21 |  |  |  |  |
22 |  |  |  |  | sub get_exclusions_for_role {
23 |  |  |  |  | my ($self, $role) = @_;
24 |  |  |  |  | $role = $role->name if blessed $role;
25 |  |  |  |  | my $excludes_key = exists $self->role_params->{$role}->{'-excludes'} ?
26 |  |  |  |  | '-excludes' : 'excludes';
27 |  |  |  |  | if ($self->role_params->{$role} && defined $self->role_params->{$role}->{$excludes_key}) {
28 |  |  |  |  | if (ref $self->role_params->{$role}->{$excludes_key} eq 'ARRAY') {
29 |  |  |  |  | return $self->role_params->{$role}->{$excludes_key};
30 |  |  |  |  | }
31 |  |  |  |  | return [ $self->role_params->{$role}->{$excludes_key} ];
32 |  |  |  |  | }
33 |  |  |  |  | return [];
34 |  |  |  |  | }
35 |  |  |  |  |
36 |  |  |  |  | sub get_method_aliases_for_role {
37 |  |  |  |  | my ($self, $role) = @_;
38 |  |  |  |  | $role = $role->name if blessed $role;
39 |  |  |  |  | my $alias_key = exists $self->role_params->{$role}->{'-alias'} ?
40 |  |  |  |  | '-alias' : 'alias';
41 |  |  |  |  | if ($self->role_params->{$role} && defined $self->role_params->{$role}->{$alias_key}) {
42 |  |  |  |  | return $self->role_params->{$role}->{$alias_key};
43 |  |  |  |  | }
44 |  |  |  |  | return {};
45 |  |  |  |  | }
46 |  |  |  |  |
47 |  |  |  |  | sub is_method_excluded {
48 |  |  |  |  | my ($self, $role, $method_name) = @_;
49 |  |  |  |  | foreach ($self->get_exclusions_for_role($role->name)) {
50 |  |  |  |  | return 1 if $_ eq $method_name;
51 |  |  |  |  | }
52 |  |  |  |  | return 0;
53 |  |  |  |  | }
54 |  |  |  |  |
55 |  |  |  |  | sub is_method_aliased {
56 |  |  |  |  | my ($self, $role, $method_name) = @_;
57 |  |  |  |  | exists $self->get_method_aliases_for_role($role->name)->{$method_name} ? 1 : 0
58 |  |  |  |  | }
59 |  |  |  |  |
60 |  |  |  |  | sub is_aliased_method {
61 |  |  |  |  | my ($self, $role, $method_name) = @_;
62 |  |  |  |  | my %aliased_names = reverse %{$self->get_method_aliases_for_role($role->name)};
63 |  |  |  |  | exists $aliased_names{$method_name} ? 1 : 0;
64 |  |  |  |  | }
65 |  |  |  |  |
66 |  |  |  |  | sub check_role_exclusions {
67 |  |  |  |  | my ($self, $c) = @_;
68 |  |  |  |  |
69 |  |  |  |  | my %excluded_roles;
70 |  |  |  |  | for my $role (@{ $c->get_roles }) {
71 |  |  |  |  | my $name = $role->name;
72 |  |  |  |  |
73 |  |  |  |  | for my $excluded ($role->get_excluded_roles_list) {
74 |  |  |  |  | push @{ $excluded_roles{$excluded} }, $name;
75 |  |  |  |  | }
76 |  |  |  |  | }
77 |  |  |  |  |
78 |  |  |  |  | foreach my $role (@{$c->get_roles}) {
79 |  |  |  |  | foreach my $excluded (keys %excluded_roles) {
80 |  |  |  |  | next unless $role->does_role($excluded);
81 |  |  |  |  |
82 |  |  |  |  | my @excluding = @{ $excluded_roles{$excluded} };
83 |  |  |  |  |
84 |  |  |  |  | require Moose;
85 |  |  |  |  | Moose->throw_error(sprintf "Conflict detected: Role%s %s exclude%s role '%s'", (@excluding == 1 ? '' : 's'), join(', ', @excluding), (@excluding == 1 ? 's' : ''), $excluded);
86 |  |  |  |  | }
87 |  |  |  |  | }
88 |  |  |  |  |
89 |  |  |  |  | $c->add_excluded_roles(keys %excluded_roles);
90 |  |  |  |  | }
91 |  |  |  |  |
92 |  |  |  |  | sub check_required_methods {
93 |  |  |  |  | my ($self, $c) = @_;
94 |  |  |  |  |
95 |  |  |  |  | my %all_required_methods =
96 |  |  |  |  | map { $_->name => $_ }
97 |  |  |  |  | map { $_->get_required_method_list }
98 |  |  |  |  | @{$c->get_roles};
99 |  |  |  |  |
100 |  |  |  |  | foreach my $role (@{$c->get_roles}) {
101 |  |  |  |  | foreach my $required (keys %all_required_methods) {
102 |  |  |  |  |
103 |  |  |  |  | delete $all_required_methods{$required}
104 |  |  |  |  | if $role->has_method($required)
105 |  |  |  |  | || $self->is_aliased_method($role, $required);
106 |  |  |  |  | }
107 |  |  |  |  | }
108 |  |  |  |  |
109 |  |  |  |  | $c->add_required_methods(values %all_required_methods);
110 |  |  |  |  | }
111 |  |  |  |  |
112 |  |  |  |  | sub check_required_attributes {
113 |  |  |  |  |
114 |  |  |  |  | }
115 |  |  |  |  |
116 |  |  |  |  | sub apply_attributes {
117 |  |  |  |  | my ($self, $c) = @_;
118 |  |  |  |  |
119 |  |  |  |  | my @all_attributes;
120 |  |  |  |  |
121 |  |  |  |  | for my $role ( @{ $c->get_roles } ) {
122 |  |  |  |  | push @all_attributes,
123 |  |  |  |  | map { $role->get_attribute($_) } $role->get_attribute_list;
124 |  |  |  |  | }
125 |  |  |  |  |
126 |  |  |  |  | my %seen;
127 |  |  |  |  | foreach my $attr (@all_attributes) {
128 |  |  |  |  | my $name = $attr->name;
129 |  |  |  |  |
130 |  |  |  |  | if ( exists $seen{$name} ) {
131 |  |  |  |  | next if $seen{$name}->is_same_as($attr);
132 |  |  |  |  |
133 |  |  |  |  | my $role1 = $seen{$name}->associated_role->name;
134 |  |  |  |  | my $role2 = $attr->associated_role->name;
135 |  |  |  |  |
136 |  |  |  |  | require Moose;
137 |  |  |  |  | Moose->throw_error(
138 |  |  |  |  | "We have encountered an attribute conflict with '$name' "
139 |  |  |  |  | . "during role composition. "
140 |  |  |  |  | . " This attribute is defined in both $role1 and $role2."
141 |  |  |  |  | . " This is fatal error and cannot be disambiguated." );
142 |  |  |  |  | }
143 |  |  |  |  |
144 |  |  |  |  | $seen{$name} = $attr;
145 |  |  |  |  | }
146 |  |  |  |  |
147 |  |  |  |  | foreach my $attr (@all_attributes) {
148 |  |  |  |  | $c->add_attribute( $attr->clone );
149 |  |  |  |  | }
150 |  |  |  |  | }
151 |  |  |  |  |
152 |  |  |  |  | sub apply_methods {
153 |  |  |  |  | my ($self, $c) = @_;
154 |  |  |  |  |
155 |  |  |  |  | my @all_methods = map {
156 |  |  |  |  | my $role = $_;
157 |  |  |  |  | my $aliases = $self->get_method_aliases_for_role($role);
158 |  |  |  |  | my %excludes = map { $_ => undef } @{ $self->get_exclusions_for_role($role) };
159 |  |  |  |  | $excludes{meta} = undef;
160 |  |  |  |  | (
161 |  |  |  |  | (map {
162 |  |  |  |  | exists $excludes{$_} ? () :
163 |  |  |  |  | +{
164 |  |  |  |  | role => $role,
165 |  |  |  |  | name => $_,
166 |  |  |  |  | method => $role->get_method($_),
167 |  |  |  |  | }
168 |  |  |  |  | } $role->get_method_list),
169 |  |  |  |  | (map {
170 |  |  |  |  | +{
171 |  |  |  |  | role => $role,
172 |  |  |  |  | name => $aliases->{$_},
173 |  |  |  |  | method => $role->get_method($_),
174 |  |  |  |  | }
175 |  |  |  |  | } keys %$aliases)
176 |  |  |  |  | );
177 |  |  |  |  | } @{$c->get_roles};
178 |  |  |  |  |
179 |  |  |  |  | my (%seen, %method_map);
180 |  |  |  |  | foreach my $method (@all_methods) {
181 |  |  |  |  | my $seen = $seen{$method->{name}};
182 |  |  |  |  |
183 |  |  |  |  | if ($seen) {
184 |  |  |  |  | if ($seen->{method}->body != $method->{method}->body) {
185 |  |  |  |  | $c->add_conflicting_method(
186 |  |  |  |  | name => $method->{name},
187 |  |  |  |  | roles => [$method->{role}->name, $seen->{role}->name],
188 |  |  |  |  | );
189 |  |  |  |  |
190 |  |  |  |  | delete $method_map{$method->{name}};
191 |  |  |  |  | next;
192 |  |  |  |  | }
193 |  |  |  |  | }
194 |  |  |  |  |
195 |  |  |  |  | $seen{$method->{name}} = $method;
196 |  |  |  |  | $method_map{$method->{name}} = $method->{method};
197 |  |  |  |  | }
198 |  |  |  |  |
199 |  |  |  |  | $c->add_method($_ => $method_map{$_}) for keys %method_map;
200 |  |  |  |  | }
201 |  |  |  |  |
202 |  |  |  |  | sub apply_override_method_modifiers {
203 |  |  |  |  | my ($self, $c) = @_;
204 |  |  |  |  |
205 |  |  |  |  | my @all_overrides = map {
206 |  |  |  |  | my $role = $_;
207 |  |  |  |  | map {
208 |  |  |  |  | +{
209 |  |  |  |  | name => $_,
210 |  |  |  |  | method => $role->get_override_method_modifier($_),
211 |  |  |  |  | }
212 |  |  |  |  | } $role->get_method_modifier_list('override');
213 |  |  |  |  | } @{$c->get_roles};
214 |  |  |  |  |
215 |  |  |  |  | my %seen;
216 |  |  |  |  | foreach my $override (@all_overrides) {
217 |  |  |  |  | if ( $c->has_method($override->{name}) ){
218 |  |  |  |  | require Moose;
219 |  |  |  |  | Moose->throw_error( "Role '" . $c->name . "' has encountered an 'override' method conflict " .
220 |  |  |  |  | "during composition (A local method of the same name as been found). This " .
221 |  |  |  |  | "is fatal error." )
222 |  |  |  |  | }
223 |  |  |  |  | if (exists $seen{$override->{name}}) {
224 |  |  |  |  | if ( $seen{$override->{name}} != $override->{method} ) {
225 |  |  |  |  | require Moose;
226 |  |  |  |  | Moose->throw_error( "We have encountered an 'override' method conflict during " .
227 |  |  |  |  | "composition (Two 'override' methods of the same name encountered). " .
228 |  |  |  |  | "This is fatal error.")
229 |  |  |  |  | }
230 |  |  |  |  | }
231 |  |  |  |  | $seen{$override->{name}} = $override->{method};
232 |  |  |  |  | }
233 |  |  |  |  |
234 |  |  |  |  | $c->add_override_method_modifier(
235 |  |  |  |  | $_->{name}, $_->{method}
236 |  |  |  |  | ) for @all_overrides;
237 |  |  |  |  |
238 |  |  |  |  | }
239 |  |  |  |  |
240 |  |  |  |  | sub apply_method_modifiers {
241 |  |  |  |  | my ($self, $modifier_type, $c) = @_;
242 |  |  |  |  | my $add = "add_${modifier_type}_method_modifier";
243 |  |  |  |  | my $get = "get_${modifier_type}_method_modifiers";
244 |  |  |  |  | foreach my $role (@{$c->get_roles}) {
245 |  |  |  |  | foreach my $method_name ($role->get_method_modifier_list($modifier_type)) {
246 |  |  |  |  | $c->$add(
247 |  |  |  |  | $method_name,
248 |  |  |  |  | $_
249 |  |  |  |  | ) foreach $role->$get($method_name);
250 |  |  |  |  | }
251 |  |  |  |  | }
252 |  |  |  |  | }
253 |  |  |  |  |
254 | 1 | 8µs |  |  | 1;
255 |  |  |  |  |
256 |  |  |  |  | __END__
257 |  |  |  |  |
258 |  |  |  |  | =pod
259 |  |  |  |  |
260 |  |  |  |  | =head1 NAME
261 |  |  |  |  |
262 |  |  |  |  | Moose::Meta::Role::Application::RoleSummation - Combine two or more roles
263 |  |  |  |  |
264 |  |  |  |  | =head1 DESCRIPTION
265 |  |  |  |  |
266 |  |  |  |  | Summation composes two traits, forming the union of non-conflicting
267 |  |  |  |  | bindings and 'disabling' the conflicting bindings
268 |  |  |  |  |
269 |  |  |  |  | =head2 METHODS
270 |  |  |  |  |
271 |  |  |  |  | =over 4
272 |  |  |  |  |
273 |  |  |  |  | =item B<new>
274 |  |  |  |  |
275 |  |  |  |  | =item B<meta>
276 |  |  |  |  |
277 |  |  |  |  | =item B<role_params>
278 |  |  |  |  |
279 |  |  |  |  | =item B<get_exclusions_for_role>
280 |  |  |  |  |
281 |  |  |  |  | =item B<get_method_aliases_for_role>
282 |  |  |  |  |
283 |  |  |  |  | =item B<is_aliased_method>
284 |  |  |  |  |
285 |  |  |  |  | =item B<is_method_aliased>
286 |  |  |  |  |
287 |  |  |  |  | =item B<is_method_excluded>
288 |  |  |  |  |
289 |  |  |  |  | =item B<apply>
290 |  |  |  |  |
291 |  |  |  |  | =item B<check_role_exclusions>
292 |  |  |  |  |
293 |  |  |  |  | =item B<check_required_methods>
294 |  |  |  |  |
295 |  |  |  |  | =item B<check_required_attributes>
296 |  |  |  |  |
297 |  |  |  |  | =item B<apply_attributes>
298 |  |  |  |  |
299 |  |  |  |  | =item B<apply_methods>
300 |  |  |  |  |
301 |  |  |  |  | =item B<apply_method_modifiers>
302 |  |  |  |  |
303 |  |  |  |  | =item B<apply_override_method_modifiers>
304 |  |  |  |  |
305 |  |  |  |  | =back
306 |  |  |  |  |
307 |  |  |  |  | =head1 BUGS
308 |  |  |  |  |
309 |  |  |  |  | See L<Moose/BUGS> for details on reporting bugs.
310 |  |  |  |  |
311 |  |  |  |  | =head1 AUTHOR
312 |  |  |  |  |
313 |  |  |  |  | Stevan Little E<lt>stevan@iinteractive.comE<gt>
314 |  |  |  |  |
315 |  |  |  |  | =head1 COPYRIGHT AND LICENSE
316 |  |  |  |  |
317 |  |  |  |  | Copyright 2006-2010 by Infinity Interactive, Inc.
318 |  |  |  |  |
319 |  |  |  |  | L<http://www.iinteractive.com>
320 |  |  |  |  |
321 |  |  |  |  | This library is free software; you can redistribute it and/or modify
322 |  |  |  |  | it under the same terms as Perl itself.
323 |  |  |  |  |
324 |  |  |  |  | =cut
325 |  |  |  |  |