MooseX::MakeImmutable - A convenient way to make many Moosen immutable (or mutable) in one shot
# MyPackage and any subdordinate Moose classes are made immutable
# Use MooseX::MakeImmutable->open_up to do the opposite
You can also make classes im/mutable with fine-grained control:
my $manifest = <<_MANIFEST_;
# Comments (lines leading with a pound) and blank lines are ignored by the finder
# Not strict about leading/trailing whitespace either
# The above code has the following effects:
# ::Alpha, ::Bravo, and ::Charlie are now immutable (if they exist)
# Every Moose::Object under the Delta:: namespace is now immutable
# (although ::Delta, if a Moose::Object, IS still mutable)
# Every Moose::Object under the Epsilon:: namespace, including
# ::Epsilon is now mutable
# You can also use MooseX::MakeImmutable to make something mutable again:
MooseX::MakeImmutable is a tool for loading every Moose::Object within a hierarchy and making each immutable/mutable. It uses Module::Pluggable for searching and will load both inner and .pm packages.
In a nutshell, if you add a Moose-based package to your object hierarchy, then MooseX::MakeImmutable, given a proper manifest, will pick it up and mark it im/mutable (without you having to manually write-out the new package).
NOTE: The name "MakeImmutable" is a bit of a misnomer, since this package can both make_immutable AND make_mutable. However, 90% of the time, you'll probably be using ->make_immutable
A manifest consists of one package per line
For each line, leading and trailing whitespace is stripped
Lines that are blank or begin with a pound (#) are skipped
A package with a trailing ::* IS NOT made im/mutable, but every package under that namespace is
A package with a trailing ::+ or :: IS made im/mutable, along with every package under that namespace
Make everything immutable from <package> on downward
If <package> is not specified, then the package will be gotten from caller. This means you can do something like:
# Effectively the same as MooseX::MakeImmutable->make_immutable('MyPackage::+');
Any remaining arguments will be passed through to ->make_immutable
Make everything mutable from <package> on downward
# Effectively the same as MooseX::MakeImmutable->make_mutable('MyPackage::+');
Any remaining arguments will be passed through to ->make_mutable
Create a finder from <manifest> and make each found Moose::Object immutable
Any extra passed-in options will be forwarded to ->meta->make_immutable(...) excepting include_inner and exclude, which are used to configure the finder.
freeze is an alias for make_immutable
Create a finder from <manifest> and make each found Moose::Object mutable
Any extra passed-in options will be forwarded to ->meta->make_mutable(...) excepting include_inner and exclude, which are used to configure the finder.
thaw is an alias for make_mutable
Create and return a MooseX::MakeImmutable::Finder object
The returned object uses Module::Pluggable to scan the specified namespace(s) for potential Moose objects. It accepts the following options:
manifest The finder manifest, described above
include_inner If true, then the finder will "find" inner Moose packages. On by default
exclude A list where each item is one of:
* A package name to be excluded (string)
* A regular expression that matches if a package should be excluded
* A CODE block returning true if a package should be excluded (the package name is passed in as the first argument)
Robert Krimen, <rkrimen at cpan.org>
<rkrimen at cpan.org>
You can contribute or fork this project via GitHub:
git clone git://github.com/robertkrimen/moosex-makeimmutable.git MooseX-MakeImmutable
Please report any bugs or feature requests to bug-moosex-mutate at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooseX-MakeImmutable. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-moosex-mutate at rt.cpan.org
You can find documentation for this module with the perldoc command.
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
Copyright 2008 Robert Krimen, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install MooseX::MakeImmutable, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.