Inline calculate_all_roles_with_inheritance when making class immutable
[gitmo/Moose.git] / lib / Moose / Meta / Class / Immutable / Trait.pm
1 package Moose::Meta::Class::Immutable::Trait;
2
3 use strict;
4 use warnings;
5
6 use Class::MOP;
7
8 our $VERSION   = '1.12';
9 $VERSION = eval $VERSION;
10 our $AUTHORITY = 'cpan:STEVAN';
11
12 use base 'Class::MOP::Class::Immutable::Trait';
13
14 sub add_role { $_[1]->_immutable_cannot_call }
15
16 sub calculate_all_roles {
17     my $orig = shift;
18     my $self = shift;
19     @{ $self->{__immutable}{calculate_all_roles} ||= [ $self->$orig ] };
20 }
21
22 sub calculate_all_roles_with_inheritance {
23     my $orig = shift;
24     my $self = shift;
25     @{ $self->{__immutable}{calculate_all_roles_with_inheritance} ||= [ $self->$orig ] };
26 }
27
28 1;
29
30 __END__
31
32 =pod
33
34 =head1 NAME
35
36 Moose::Meta::Class::Immutable::Trait - Implements immutability for metaclass objects
37
38 =head1 DESCRIPTION
39
40 This class makes some Moose-specific metaclass methods immutable. This
41 is deep guts.
42
43 =head1 BUGS
44
45 See L<Moose/BUGS> for details on reporting bugs.
46
47 =head1 AUTHOR
48
49 Yuval Kogman E<lt>nothingmuch@cpan.orgE<gt>
50
51 =head1 COPYRIGHT AND LICENSE
52
53 Copyright 2009 by Infinity Interactive, Inc.
54
55 L<http://www.iinteractive.com>
56
57 This library is free software; you can redistribute it and/or modify
58 it under the same terms as Perl itself.
59
60 =cut
61