| Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Role/Application/ToInstance.pm |
| Statements | Executed 17 statements in 314µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 11µs | 11µs | Moose::Meta::Role::Application::ToInstance::BEGIN@2 |
| 1 | 1 | 1 | 6µs | 9µs | Moose::Meta::Role::Application::ToInstance::BEGIN@10 |
| 1 | 1 | 1 | 6µs | 27µs | Moose::Meta::Role::Application::ToInstance::BEGIN@13 |
| 1 | 1 | 1 | 6µs | 23µs | Moose::Meta::Role::Application::ToInstance::BEGIN@14 |
| 1 | 1 | 1 | 6µs | 16µs | Moose::Meta::Role::Application::ToInstance::BEGIN@9 |
| 1 | 1 | 1 | 5µs | 336µs | Moose::Meta::Role::Application::ToInstance::BEGIN@11 |
| 1 | 1 | 1 | 5µs | 55µ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 11µs within Moose::Meta::Role::Application::ToInstance::BEGIN@2 which was called:
# once (11µs+0s) by Moose::BEGIN@41 at line 4 | ||||
| 3 | 1 | 4µs | $Moose::Meta::Role::Application::ToInstance::AUTHORITY = 'cpan:STEVAN'; | ||
| 4 | 1 | 28µs | 1 | 11µs | } # spent 11µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@2 |
| 5 | { | ||||
| 6 | 2 | 700ns | $Moose::Meta::Role::Application::ToInstance::VERSION = '2.1005'; | ||
| 7 | } | ||||
| 8 | |||||
| 9 | 2 | 20µs | 2 | 26µs | # spent 16µs (6+10) within Moose::Meta::Role::Application::ToInstance::BEGIN@9 which was called:
# once (6µs+10µs) by Moose::BEGIN@41 at line 9 # spent 16µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@9
# spent 10µs making 1 call to strict::import |
| 10 | 2 | 19µs | 2 | 12µs | # spent 9µs (6+3) within Moose::Meta::Role::Application::ToInstance::BEGIN@10 which was called:
# once (6µs+3µs) by Moose::BEGIN@41 at line 10 # spent 9µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@10
# spent 3µs making 1 call to warnings::import |
| 11 | 2 | 25µs | 2 | 666µs | # spent 336µs (5+330) within Moose::Meta::Role::Application::ToInstance::BEGIN@11 which was called:
# once (5µs+330µs) by Moose::BEGIN@41 at line 11 # spent 336µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@11
# spent 330µs making 1 call to metaclass::import |
| 12 | |||||
| 13 | 2 | 22µs | 2 | 47µs | # spent 27µs (6+20) within Moose::Meta::Role::Application::ToInstance::BEGIN@13 which was called:
# once (6µs+20µs) by Moose::BEGIN@41 at line 13 # spent 27µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@13
# spent 20µs making 1 call to Exporter::import |
| 14 | 2 | 22µs | 2 | 41µs | # spent 23µs (6+17) within Moose::Meta::Role::Application::ToInstance::BEGIN@14 which was called:
# once (6µs+17µs) by Moose::BEGIN@41 at line 14 # spent 23µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@14
# spent 17µs making 1 call to Exporter::import |
| 15 | |||||
| 16 | 2 | 164µs | 2 | 104µs | # spent 55µs (5+49) within Moose::Meta::Role::Application::ToInstance::BEGIN@16 which was called:
# once (5µs+49µs) by Moose::BEGIN@41 at line 16 # spent 55µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@16
# spent 49µs making 1 call to base::import |
| 17 | |||||
| 18 | __PACKAGE__->meta->add_attribute('rebless_params' => ( | ||||
| 19 | reader => 'rebless_params', | ||||
| 20 | default => sub { {} }, | ||||
| 21 | 1 | 5µs | 3 | 300µs | Class::MOP::_definition_context(), # spent 282µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 13µs making 1 call to Moose::Meta::Role::Application::ToInstance::meta
# spent 5µ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 | 4µs | 1; | ||
| 45 | |||||
| 46 | # ABSTRACT: Compose a role into an instance | ||||
| 47 | |||||
| 48 | __END__ |