- CONFIGURATION AND ENVIRONMENT
- SEE ALSO
- BUGS AND LIMITATIONS
- LICENCE AND COPYRIGHT
- DISCLAIMER OF WARRANTY
Role::Multiton::New - Turn your new() into a multiton constructor
This document describes Role::Multiton::New version 0.2
package ZeroCool ## no critic (RequireUseStrict) - Moo does strict use Moo; with 'Role::Multiton::New'; …
use ZeroCool; my $z3r0 = ZeroCool->new(…)->turn_new_into_multiton; # from now on new() returns a multiton (see Role::Multiton if you want to keep new() as-is and add multition support)
See Role::Multiton for more information on multitons. Then see INTERFACE for specifics of what this module does.
This role allows you to turn new() into a multiton constructor.
This is useful, for example, when a multiton makes sense but you can't change all the new() calls to singleton() or instance(). It might also be useful for testing so you can reliably operate on the same object.
Unfortunately one can not do this automatically via, say,
around 'new' because new() is built up along the way. See rt 89239 for some specifics.
The seeming quantum state of new() is fixed however after it is called once. At that point it is possible to operate on it which is what turn_new_into_multiton() does.
You'll probably want to only call this on the final object as calling it on any supers will effect subsequent extenders.
This must be called with an object (to ensure new() has been called and is final). It returns the object so that it is safe to call in a chain the SYNOPSIS.
Subsequent calls will result in the multiton object being changed to the caller of turn_new_into_singleton(), probably a no-op most of the time.
Throws no warnings or errors of its own.
CONFIGURATION AND ENVIRONMENT
Role::Multiton::New requires no configuration files or environment variables.
See "INCOMPATIBILITIES" in Role::Multiton for info about object system specific compatibility.
BUGS AND LIMITATIONS
No bugs have been reported.
Please report any bugs or feature requests to
firstname.lastname@example.org, or through the web interface at http://rt.cpan.org.
LICENCE AND COPYRIGHT
Copyright (c) 2013, Daniel Muey
<http://drmuey.com/cpan_contact.pl>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.