Here's a simple use case for MooseX::MungeHas. View this files's source code for the full script.
We use an environment variable to toggle type constraint checks:
use MooseX::MungeHas $ENV{PERL_FASTER} ? qw(is_ro no_isa) : qw(is_ro);
When the code is run normally (e.g. on a development machine), the no_isa munger is not in effect. When run on a machine with the PERL_FASTER environment variable set to true (e.g. on the production machine), the no_isa munger strings into action, and type constraints cease to be checked. (Because any type errors would have cropped up on the development machines, right??)
no_isa
PERL_FASTER
Your machine is probably faster than mine, but a typical output with PERL_FASTER false is:
Completed run in: 0.002362 s.
And with PERL_FASTER true:
Completed run in: 0.001246 s.
Example requires Moose and Types::Standard.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2013 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install MooseX::MungeHas, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::MungeHas
CPAN shell
perl -MCPAN -e shell install MooseX::MungeHas
For more information on module installation, please visit the detailed CPAN module installation guide.