5 Moose::Cookbook::Snack::Keywords - Restricted keywords in Moose
9 There are several keywords exported by L<Moose> that can cause clashes
10 against other user-defined barewords. The following document provides
11 a list of those keywords in a single place for easy reference.
13 =head2 The 'meta' keyword
15 While most of the reserved keywords collisions can be avoided, however
16 I<meta> is the only one you B<can not> override. Do not attempt to override
17 I<meta>, it will break the Moose internals.
21 If you are using L<Moose> or L<Moose::Role> its best to avoid these
52 =head2 Moose::Util::TypeConstraints Keywords
54 If you are using L<Moose::Util::TypeConstraints> its best to avoid
83 =item find_type_constraint
85 =item register_type_constraint
89 =head2 Avoiding collisions
91 =head3 Turning off Moose
93 To remove the keywords L<Moose> exports just add C<no Moose> at the bottom of
103 This will un-export the keywords that L<Moose> originally exported. The same
104 will also work for L<Moose::Role> and L<Moose::Util::TypeConstraints>. It is
105 general L<Moose> policy that this feature is used.
109 L<Moose>, L<Moose::Role> and L<Moose::Util::TypeConstraints> all use
110 L<Sub::Exporter> to handle all their exporting needs. This means that all the
111 features that L<Sub::Exporter> provides are also available to them.
113 For instance, with L<Sub::Exporter> you can rename keywords, like so:
116 use Moose 'has' => { -as => 'i_can_haz' };
118 i_can_haz 'cheeseburger' => (
120 trigger => sub { print "NOM NOM" }
123 LOL::Cat->new->cheeseburger('KTHNXBYE');
125 See the L<Sub::Exporter> docs for more information.
127 =head3 namespace::clean
129 You can also use L<namespace::clean> to clean up your namespace, but you must
130 be careful not to remove C<meta> with this. Here is an example of that usage:
134 use namespace::clean -except => 'meta';
145 =item L<Moose::Utils::TypeConstraints>
147 =item L<Sub::Exporter>
149 =item L<namespace::clean>
155 John Goulah C<E<lt>jgoulah@cpan.org<gt>>
157 Stevan Little E<lt>stevan@iinteractive.comE<gt>
159 =head1 COPYRIGHT AND LICENSE
161 Copyright 2006-2008 by Infinity Interactive, Inc.
163 L<http://www.iinteractive.com>
165 This library is free software; you can redistribute it and/or modify
166 it under the same terms as Perl itself.