MooX::Failover - Instantiate Moo classes with failover
v0.3.3
# In your class: package MyClass; use Moo; use MooX::Failover; has 'attr' => ( ... ); # after attributes are defined: failover_to 'OtherClass'; ... # When using the class my $obj = MyClass->new( %args ); # If %args contains missing or invalid values or new otherwise # fails, then $obj will be of type "OtherClass".
See How to install CPAN modules.
This distribution requires Perl v5.10.0.
This distribution requires the following modules:
Class::Load (version 0.20)
Moo
Sub::Defer
Sub::Quote
Test::Most
Types::Standard
This distribution recommends the following modules:
Class::Load::XS
Minor tweaks to Changes file.
Moved test prerequisties into test phase.
See the Changes file for a longer revision history.
This module provides constructor failover for Moo classes.
For example, if a class cannot be instantiated because of invalid arguments (perhaps from an untrusted source), then instead it returns the failover class (passing the same arguments to that class).
It is roughly equivalent to using
my $obj = eval { MyClass->new(%args) // OtherClass->new( %args, error => $@ );
This allows for cleaner design, by not forcing you to duplicate type checking for constructor parameters.
See the module documentation for MooX::Failover for more information.
This was originally a Moo port of MooseX::Failover. The interface was redesigned significantly, to be more efficient.
Robert Rothenberg <rrwo@thermeon.com>
<rrwo@thermeon.com
Copyright 2014 Thermeon Worldwide, PLC.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.
To install MooX::Failover, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooX::Failover
CPAN shell
perl -MCPAN -e shell install MooX::Failover
For more information on module installation, please visit the detailed CPAN module installation guide.