| File | /usr/local/lib/perl/5.10.0/Moose/Meta/Class/Immutable/Trait.pm |
| Statements Executed | 19 |
| Total Time | 0.0004732 seconds |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::Immutable::Trait::BEGIN |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::Immutable::Trait::add_role |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::Immutable::Trait::calculate_all_roles |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::Immutable::Trait::calculate_all_roles_with_inheritance |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::Immutable::Trait::does_role |
| Line | Stmts. | Exclusive Time | Avg. | Code |
|---|---|---|---|---|
| 1 | package Moose::Meta::Class::Immutable::Trait; | |||
| 2 | ||||
| 3 | 3 | 32µs | 11µs | use strict; # spent 11µs making 1 call to strict::import |
| 4 | 3 | 24µs | 8µs | use warnings; # spent 29µs making 1 call to warnings::import |
| 5 | ||||
| 6 | 3 | 32µs | 11µs | use Class::MOP; # spent 3µs making 1 call to import |
| 7 | 3 | 69µs | 23µs | use Scalar::Util qw( blessed ); # spent 57µs making 1 call to Exporter::import |
| 8 | ||||
| 9 | 1 | 700ns | 700ns | our $VERSION = '1.15'; |
| 10 | 1 | 27µs | 27µs | $VERSION = eval $VERSION; |
| 11 | 1 | 600ns | 600ns | our $AUTHORITY = 'cpan:STEVAN'; |
| 12 | ||||
| 13 | 3 | 285µs | 95µs | use base 'Class::MOP::Class::Immutable::Trait'; # spent 85µs making 1 call to base::import |
| 14 | ||||
| 15 | sub add_role { $_[1]->_immutable_cannot_call } | |||
| 16 | ||||
| 17 | sub calculate_all_roles { | |||
| 18 | my $orig = shift; | |||
| 19 | my $self = shift; | |||
| 20 | @{ $self->{__immutable}{calculate_all_roles} ||= [ $self->$orig ] }; | |||
| 21 | } | |||
| 22 | ||||
| 23 | sub calculate_all_roles_with_inheritance { | |||
| 24 | my $orig = shift; | |||
| 25 | my $self = shift; | |||
| 26 | @{ $self->{__immutable}{calculate_all_roles_with_inheritance} ||= [ $self->$orig ] }; | |||
| 27 | } | |||
| 28 | ||||
| 29 | sub does_role { | |||
| 30 | shift; | |||
| 31 | my $self = shift; | |||
| 32 | my $role = shift; | |||
| 33 | ||||
| 34 | (defined $role) | |||
| 35 | || $self->throw_error("You must supply a role name to look for"); | |||
| 36 | ||||
| 37 | $self->{__immutable}{does_role} ||= { map { $_->name => 1 } $self->calculate_all_roles_with_inheritance }; | |||
| 38 | ||||
| 39 | my $name = blessed $role ? $role->name : $role; | |||
| 40 | ||||
| 41 | return $self->{__immutable}{does_role}{$name}; | |||
| 42 | } | |||
| 43 | ||||
| 44 | 1 | 4µs | 4µs | 1; |
| 45 | ||||
| 46 | __END__ | |||
| 47 | ||||
| 48 | =pod | |||
| 49 | ||||
| 50 | =head1 NAME | |||
| 51 | ||||
| 52 | Moose::Meta::Class::Immutable::Trait - Implements immutability for metaclass objects | |||
| 53 | ||||
| 54 | =head1 DESCRIPTION | |||
| 55 | ||||
| 56 | This class makes some Moose-specific metaclass methods immutable. This | |||
| 57 | is deep guts. | |||
| 58 | ||||
| 59 | =head1 BUGS | |||
| 60 | ||||
| 61 | See L<Moose/BUGS> for details on reporting bugs. | |||
| 62 | ||||
| 63 | =head1 AUTHOR | |||
| 64 | ||||
| 65 | Yuval Kogman E<lt>nothingmuch@cpan.orgE<gt> | |||
| 66 | ||||
| 67 | =head1 COPYRIGHT AND LICENSE | |||
| 68 | ||||
| 69 | Copyright 2009 by Infinity Interactive, Inc. | |||
| 70 | ||||
| 71 | L<http://www.iinteractive.com> | |||
| 72 | ||||
| 73 | This library is free software; you can redistribute it and/or modify | |||
| 74 | it under the same terms as Perl itself. | |||
| 75 | ||||
| 76 | =cut | |||
| 77 |