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
54 =head2 Moose::Util::TypeConstraints Keywords
56 If you are using L<Moose::Util::TypeConstraints> its best to avoid
85 =item find_type_constraint
87 =item register_type_constraint
91 =head2 Avoiding collisions
93 =head3 Turning off Moose
95 To remove the keywords L<Moose> exports just add C<no Moose> at the bottom of
105 This will un-export the keywords that L<Moose> originally exported. The same
106 will also work for L<Moose::Role> and L<Moose::Util::TypeConstraints>. It is
107 general L<Moose> policy that this feature is used.
111 L<Moose>, L<Moose::Role> and L<Moose::Util::TypeConstraints> all use
112 L<Sub::Exporter> to handle all their exporting needs. This means that all the
113 features that L<Sub::Exporter> provides are also available to them.
115 For instance, with L<Sub::Exporter> you can rename keywords, like so:
118 use Moose 'has' => { -as => 'i_can_haz' };
120 i_can_haz 'cheeseburger' => (
122 trigger => sub { print "NOM NOM" }
125 LOL::Cat->new->cheeseburger('KTHNXBYE');
127 See the L<Sub::Exporter> docs for more information.
129 =head3 namespace::clean
131 You can also use L<namespace::clean> to clean up your namespace, but you must
132 be careful not to remove C<meta> with this. Here is an example of that usage:
136 use namespace::clean -except => 'meta';
147 =item L<Moose::Utils::TypeConstraints>
149 =item L<Sub::Exporter>
151 =item L<namespace::clean>
157 John Goulah C<E<lt>jgoulah@cpan.org<gt>>
159 Stevan Little E<lt>stevan@iinteractive.comE<gt>
161 =head1 COPYRIGHT AND LICENSE
163 Copyright 2006-2008 by Infinity Interactive, Inc.
165 L<http://www.iinteractive.com>
167 This library is free software; you can redistribute it and/or modify
168 it under the same terms as Perl itself.