NAME
Moose::Cookbook::Snack::Keywords - Restricted keywords in Moose
DESCRIPTION
There are several keywords exported in Moose that cause clashes against any barewords such as attribute names, sub names, and globs.
The 'meta' keyword
While most of the reserved keywords collisions can be avoided, however meta is the only one you cant override. Do not attempt to override meta.
Moose Keywords
If you are using Moose its best to avoid these keywords
- extends
- with
- has
- before
- after
- around
- super
- override
- inner
- augment
- make_immutable
- confess
- blessed
Moose::Util::TypeConstraints Keywords
If you are using Moose::Util::TypeConstraints its best to avoid these keywords
- type
- subtype
- class_type
- role_type
- as
- where
- message
- optimize_as
- coerce
- from
- via
- enum
- find_type_constraint
- register_type_constraint
Avoiding collisions
Turning off Moose
To remove the keywords Moose exports using no Moose at the bottom of your code
package Thing;
use Moose;
# code here
no Moose;
Sub::Exporter
The Sub::Exporter module can rename keywords
package LOL::Cat;
use Moose 'has' => { -as => 'i_can_haz' };
i_can_haz 'cheeseburger' => (
is => 'rw',
trigger => sub { print "NOM NOM" }
);
LOL::Cat->new->cheeseburger('KTHNXBYE');;
namespace::clean
You can use namespace::clean to clean up the namespace
AUTHOR AND COPYRIGHT
John Goulah <jgoulah@cpan.org<gt
>
LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as perl itself.