| Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Meta/Role/Application/ToInstance.pm |
| Statements | Executed 23 statements in 329µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 9µs | 9µs | Moose::Meta::Role::Application::ToInstance::BEGIN@2 |
| 1 | 1 | 1 | 9µs | 14µs | Moose::Meta::Role::Application::ToInstance::BEGIN@9 |
| 1 | 1 | 1 | 9µs | 44µs | Moose::Meta::Role::Application::ToInstance::BEGIN@13 |
| 1 | 1 | 1 | 8µs | 566µs | Moose::Meta::Role::Application::ToInstance::BEGIN@11 |
| 1 | 1 | 1 | 8µs | 24µs | Moose::Meta::Role::Application::ToInstance::BEGIN@10 |
| 1 | 1 | 1 | 8µs | 34µs | Moose::Meta::Role::Application::ToInstance::BEGIN@14 |
| 1 | 1 | 1 | 8µs | 77µs | Moose::Meta::Role::Application::ToInstance::BEGIN@16 |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Application::ToInstance::__ANON__[:20] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Application::ToInstance::__ANON__[:38] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Application::ToInstance::apply |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moose::Meta::Role::Application::ToInstance; | ||||
| 2 | # spent 9µs within Moose::Meta::Role::Application::ToInstance::BEGIN@2 which was called:
# once (9µs+0s) by Moose::BEGIN@42 at line 4 | ||||
| 3 | 1 | 5µs | $Moose::Meta::Role::Application::ToInstance::AUTHORITY = 'cpan:STEVAN'; | ||
| 4 | 1 | 25µs | 1 | 9µs | } # spent 9µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@2 |
| 5 | { | ||||
| 6 | 2 | 1µs | $Moose::Meta::Role::Application::ToInstance::VERSION = '2.0602'; | ||
| 7 | } | ||||
| 8 | |||||
| 9 | 3 | 19µs | 2 | 19µs | # spent 14µs (9+5) within Moose::Meta::Role::Application::ToInstance::BEGIN@9 which was called:
# once (9µs+5µs) by Moose::BEGIN@42 at line 9 # spent 14µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@9
# spent 5µs making 1 call to strict::import |
| 10 | 3 | 18µs | 2 | 40µs | # spent 24µs (8+16) within Moose::Meta::Role::Application::ToInstance::BEGIN@10 which was called:
# once (8µs+16µs) by Moose::BEGIN@42 at line 10 # spent 24µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@10
# spent 16µs making 1 call to warnings::import |
| 11 | 3 | 28µs | 2 | 1.12ms | # spent 566µs (8+557) within Moose::Meta::Role::Application::ToInstance::BEGIN@11 which was called:
# once (8µs+557µs) by Moose::BEGIN@42 at line 11 # spent 566µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@11
# spent 557µs making 1 call to metaclass::import |
| 12 | |||||
| 13 | 3 | 21µs | 2 | 80µs | # spent 44µs (9+36) within Moose::Meta::Role::Application::ToInstance::BEGIN@13 which was called:
# once (9µs+36µs) by Moose::BEGIN@42 at line 13 # spent 44µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@13
# spent 35µs making 1 call to Exporter::import |
| 14 | 3 | 20µs | 2 | 61µs | # spent 34µs (8+27) within Moose::Meta::Role::Application::ToInstance::BEGIN@14 which was called:
# once (8µs+27µs) by Moose::BEGIN@42 at line 14 # spent 34µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@14
# spent 27µs making 1 call to Exporter::import |
| 15 | |||||
| 16 | 3 | 180µs | 2 | 146µs | # spent 77µs (8+69) within Moose::Meta::Role::Application::ToInstance::BEGIN@16 which was called:
# once (8µs+69µs) by Moose::BEGIN@42 at line 16 # spent 77µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@16
# spent 69µs making 1 call to base::import |
| 17 | |||||
| 18 | __PACKAGE__->meta->add_attribute('rebless_params' => ( | ||||
| 19 | reader => 'rebless_params', | ||||
| 20 | default => sub { {} }, | ||||
| 21 | 1 | 7µs | 3 | 478µs | Class::MOP::_definition_context(), # spent 453µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 16µs making 1 call to Moose::Meta::Role::Application::ToInstance::meta
# spent 9µs making 1 call to Class::MOP::_definition_context |
| 22 | )); | ||||
| 23 | |||||
| 24 | sub apply { | ||||
| 25 | my ( $self, $role, $object, $args ) = @_; | ||||
| 26 | |||||
| 27 | my $obj_meta = Class::MOP::class_of($object) || 'Moose::Meta::Class'; | ||||
| 28 | |||||
| 29 | # This is a special case to handle the case where the object's metaclass | ||||
| 30 | # is a Class::MOP::Class, but _not_ a Moose::Meta::Class (for example, | ||||
| 31 | # when applying a role to a Moose::Meta::Attribute object). | ||||
| 32 | $obj_meta = 'Moose::Meta::Class' | ||||
| 33 | unless $obj_meta->isa('Moose::Meta::Class'); | ||||
| 34 | |||||
| 35 | my $class = $obj_meta->create_anon_class( | ||||
| 36 | superclasses => [ blessed($object) ], | ||||
| 37 | roles => [ $role, keys(%$args) ? ($args) : () ], | ||||
| 38 | cache => (all { $_ eq '-alias' || $_ eq '-excludes' } keys %$args), | ||||
| 39 | ); | ||||
| 40 | |||||
| 41 | $class->rebless_instance( $object, %{ $self->rebless_params } ); | ||||
| 42 | } | ||||
| 43 | |||||
| 44 | 1 | 6µs | 1; | ||
| 45 | |||||
| 46 | # ABSTRACT: Compose a role into an instance | ||||
| 47 | |||||
| - - | |||||
| 50 | =pod | ||||
| 51 | |||||
| 52 | =head1 NAME | ||||
| 53 | |||||
| 54 | Moose::Meta::Role::Application::ToInstance - Compose a role into an instance | ||||
| 55 | |||||
| 56 | =head1 VERSION | ||||
| 57 | |||||
| 58 | version 2.0602 | ||||
| 59 | |||||
| 60 | =head1 DESCRIPTION | ||||
| 61 | |||||
| 62 | =head2 METHODS | ||||
| 63 | |||||
| 64 | =over 4 | ||||
| 65 | |||||
| 66 | =item B<new> | ||||
| 67 | |||||
| 68 | =item B<meta> | ||||
| 69 | |||||
| 70 | =item B<apply> | ||||
| 71 | |||||
| 72 | =item B<rebless_params> | ||||
| 73 | |||||
| 74 | =back | ||||
| 75 | |||||
| 76 | =head1 BUGS | ||||
| 77 | |||||
| 78 | See L<Moose/BUGS> for details on reporting bugs. | ||||
| 79 | |||||
| 80 | =head1 AUTHOR | ||||
| 81 | |||||
| 82 | Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details. | ||||
| 83 | |||||
| 84 | =head1 COPYRIGHT AND LICENSE | ||||
| 85 | |||||
| 86 | This software is copyright (c) 2012 by Infinity Interactive, Inc.. | ||||
| 87 | |||||
| 88 | This is free software; you can redistribute it and/or modify it under | ||||
| 89 | the same terms as the Perl 5 programming language system itself. | ||||
| 90 | |||||
| 91 | =cut | ||||
| 92 | |||||
| 93 | |||||
| 94 | __END__ |