| Filename | /usr/local/lib/perl/5.18.2/Moose/Meta/Role/Application/ToInstance.pm |
| Statements | Executed 21 statements in 397µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 14µs | 55µs | Moose::Meta::Role::Application::ToInstance::BEGIN@9 |
| 1 | 1 | 1 | 11µs | 36µs | Moose::Meta::Role::Application::ToInstance::BEGIN@10 |
| 1 | 1 | 1 | 10µs | 20µs | Moose::Meta::Role::Application::ToInstance::BEGIN@4 |
| 1 | 1 | 1 | 10µs | 51µs | Moose::Meta::Role::Application::ToInstance::BEGIN@20 |
| 1 | 1 | 1 | 8µs | 34µs | Moose::Meta::Role::Application::ToInstance::BEGIN@8 |
| 1 | 1 | 1 | 7µs | 11µs | Moose::Meta::Role::Application::ToInstance::BEGIN@5 |
| 1 | 1 | 1 | 6µs | 23µs | Moose::Meta::Role::Application::ToInstance::BEGIN@12 |
| 1 | 1 | 1 | 6µs | 356µs | Moose::Meta::Role::Application::ToInstance::BEGIN@6 |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Application::ToInstance::__ANON__[:16] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Application::ToInstance::__ANON__[:36] |
| 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 | 1 | 500ns | our $VERSION = '2.1604'; | ||
| 3 | |||||
| 4 | 2 | 21µs | 2 | 29µs | # spent 20µs (10+10) within Moose::Meta::Role::Application::ToInstance::BEGIN@4 which was called:
# once (10µs+10µs) by Moose::BEGIN@38 at line 4 # spent 20µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@4
# spent 10µs making 1 call to strict::import |
| 5 | 2 | 19µs | 2 | 14µs | # spent 11µs (7+4) within Moose::Meta::Role::Application::ToInstance::BEGIN@5 which was called:
# once (7µs+4µs) by Moose::BEGIN@38 at line 5 # spent 11µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@5
# spent 4µs making 1 call to warnings::import |
| 6 | 2 | 27µs | 2 | 706µs | # spent 356µs (6+350) within Moose::Meta::Role::Application::ToInstance::BEGIN@6 which was called:
# once (6µs+350µs) by Moose::BEGIN@38 at line 6 # spent 356µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@6
# spent 350µs making 1 call to metaclass::import |
| 7 | |||||
| 8 | 2 | 27µs | 2 | 61µs | # spent 34µs (8+27) within Moose::Meta::Role::Application::ToInstance::BEGIN@8 which was called:
# once (8µs+27µs) by Moose::BEGIN@38 at line 8 # spent 34µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@8
# spent 27µs making 1 call to Exporter::import |
| 9 | 3 | 45µs | 3 | 79µs | # spent 55µs (14+41) within Moose::Meta::Role::Application::ToInstance::BEGIN@9 which was called:
# once (14µs+41µs) by Moose::BEGIN@38 at line 9 # spent 55µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@9
# spent 14µs making 1 call to UNIVERSAL::VERSION
# spent 10µs making 1 call to List::Util::import |
| 10 | 3 | 35µs | 3 | 62µs | # spent 36µs (11+25) within Moose::Meta::Role::Application::ToInstance::BEGIN@10 which was called:
# once (11µs+25µs) by Moose::BEGIN@38 at line 10 # spent 36µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@10
# spent 17µs making 1 call to Exporter::import
# spent 8µs making 1 call to UNIVERSAL::VERSION |
| 11 | |||||
| 12 | 2 | 59µs | 2 | 40µs | # spent 23µs (6+17) within Moose::Meta::Role::Application::ToInstance::BEGIN@12 which was called:
# once (6µs+17µs) by Moose::BEGIN@38 at line 12 # spent 23µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@12
# spent 17µs making 1 call to parent::import |
| 13 | |||||
| 14 | __PACKAGE__->meta->add_attribute('rebless_params' => ( | ||||
| 15 | reader => 'rebless_params', | ||||
| 16 | default => sub { {} }, | ||||
| 17 | 1 | 6µs | 3 | 328µs | Class::MOP::_definition_context(), # spent 310µ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 |
| 18 | )); | ||||
| 19 | |||||
| 20 | 2 | 154µs | 2 | 92µs | # spent 51µs (10+41) within Moose::Meta::Role::Application::ToInstance::BEGIN@20 which was called:
# once (10µs+41µs) by Moose::BEGIN@38 at line 20 # spent 51µs making 1 call to Moose::Meta::Role::Application::ToInstance::BEGIN@20
# spent 41µs making 1 call to constant::import |
| 21 | |||||
| 22 | sub apply { | ||||
| 23 | my ( $self, $role, $object, $args ) = @_; | ||||
| 24 | |||||
| 25 | my $obj_meta = Class::MOP::class_of($object) || 'Moose::Meta::Class'; | ||||
| 26 | |||||
| 27 | # This is a special case to handle the case where the object's metaclass | ||||
| 28 | # is a Class::MOP::Class, but _not_ a Moose::Meta::Class (for example, | ||||
| 29 | # when applying a role to a Moose::Meta::Attribute object). | ||||
| 30 | $obj_meta = 'Moose::Meta::Class' | ||||
| 31 | unless $obj_meta->isa('Moose::Meta::Class'); | ||||
| 32 | |||||
| 33 | my $class = $obj_meta->create_anon_class( | ||||
| 34 | superclasses => [ blessed($object) ], | ||||
| 35 | roles => [ $role, keys(%$args) ? ($args) : () ], | ||||
| 36 | cache => (all { $_ eq '-alias' || $_ eq '-excludes' } keys %$args), | ||||
| 37 | ); | ||||
| 38 | |||||
| 39 | $class->rebless_instance( $object, %{ $self->rebless_params } ); | ||||
| 40 | |||||
| 41 | if ( _NEED_OVERLOAD_HACK_FOR_OBJECTS | ||||
| 42 | && is_overloaded( ref $object ) ) { | ||||
| 43 | |||||
| 44 | # need to use $_[2] here to apply to the object in the caller | ||||
| 45 | _reset_amagic($_[2]); | ||||
| 46 | } | ||||
| 47 | |||||
| 48 | return $object; | ||||
| 49 | } | ||||
| 50 | |||||
| 51 | 1 | 4µs | 1; | ||
| 52 | |||||
| 53 | # ABSTRACT: Compose a role into an instance | ||||
| 54 | |||||
| 55 | __END__ |