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