← Index
Performance Profile   « block view • line view • sub view »
For t/test-parsing
  Run on Sun Nov 14 09:49:57 2010
Reported on Sun Nov 14 09:50:09 2010

File /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Application/ToInstance.pm
Statements Executed 20
Total Time 0.0004215 seconds
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
0000s0sMoose::Meta::Role::Application::ToInstance::::BEGINMoose::Meta::Role::Application::ToInstance::BEGIN
0000s0sMoose::Meta::Role::Application::ToInstance::::__ANON__[:17]Moose::Meta::Role::Application::ToInstance::__ANON__[:17]
0000s0sMoose::Meta::Role::Application::ToInstance::::applyMoose::Meta::Role::Application::ToInstance::apply
LineStmts.Exclusive
Time
Avg.Code
1package Moose::Meta::Role::Application::ToInstance;
2
3325µs8µsuse strict;
# spent 9µs making 1 call to strict::import
4328µs9µsuse warnings;
# spent 36µs making 1 call to warnings::import
5348µs16µsuse metaclass;
# spent 843µs making 1 call to metaclass::import
6
7374µs25µsuse Scalar::Util 'blessed';
# spent 58µs making 1 call to Exporter::import
8
91800ns800nsour $VERSION = '1.15';
10122µs22µs$VERSION = eval $VERSION;
111500ns500nsour $AUTHORITY = 'cpan:STEVAN';
12
133192µs64µsuse base 'Moose::Meta::Role::Application';
# spent 73µs making 1 call to base::import
14
15__PACKAGE__->meta->add_attribute('rebless_params' => (
16 reader => 'rebless_params',
17 default => sub { {} }
18121µs21µs));
# spent 587µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 25µs making 1 call to Moose::Meta::Role::Application::ToInstance::meta
19
20sub apply {
21 my ( $self, $role, $object, $args ) = @_;
22
23 my $obj_meta = Class::MOP::class_of($object) || 'Moose::Meta::Class';
24
25 # This is a special case to handle the case where the object's metaclass
26 # is a Class::MOP::Class, but _not_ a Moose::Meta::Class (for example,
27 # when applying a role to a Moose::Meta::Attribute object).
28 $obj_meta = 'Moose::Meta::Class'
29 unless $obj_meta->isa('Moose::Meta::Class');
30
31 my $class = $obj_meta->create_anon_class(
32 superclasses => [ blessed($object) ],
33 roles => [ $role, keys(%$args) ? ($args) : () ],
34 cache => 1,
35 );
36
37 $class->rebless_instance( $object, %{ $self->rebless_params } );
38}
39
4019µs9µs1;
41
42__END__
43
44=pod
45
46=head1 NAME
47
48Moose::Meta::Role::Application::ToInstance - Compose a role into an instance
49
50=head1 DESCRIPTION
51
52=head2 METHODS
53
54=over 4
55
56=item B<new>
57
58=item B<meta>
59
60=item B<apply>
61
62=item B<rebless_params>
63
64=back
65
66=head1 BUGS
67
68See L<Moose/BUGS> for details on reporting bugs.
69
70=head1 AUTHOR
71
72Stevan Little E<lt>stevan@iinteractive.comE<gt>
73
74=head1 COPYRIGHT AND LICENSE
75
76Copyright 2006-2010 by Infinity Interactive, Inc.
77
78L<http://www.iinteractive.com>
79
80This library is free software; you can redistribute it and/or modify
81it under the same terms as Perl itself.
82
83=cut
84