Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/robrwo/moox-failover

Instantiate Moo classes with failover
https://github.com/robrwo/moox-failover

Last synced: 11 days ago
JSON representation

Instantiate Moo classes with failover

Awesome Lists containing this project

README

        

=head1 NAME

MooX::Failover - Instantiate Moo classes with failover

=head1 VERSION

v0.3.4

=head1 SYNOPSIS

# 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".

=head1 INSTALLATION

See
L.

=head2 Required Modules

This distribution requires Perl v5.10.1.

This distribution requires the following modules:

=over 4

=item * L (version 0.20)

=item * L

=item * L

=item * L

=item * L

=item * L

=back

This distribution recommends the following modules:

=over 4

=item * L

=back

=head1 RECENT CHANGES

=head2 Documentation

=over 4

=item *

Fixed typos in Changes file (v0.3.3 was broken up into two sections).

=back

See the F file for a longer revision history.

=head1 DESCRIPTION

This module provides constructor failover for L 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 L for more information.

=head1 SEE ALSO

This was originally a L port of L. The
interface was redesigned significantly, to be more efficient.

=head1 AUTHOR

Robert Rothenberg C<>

=head2 Acknowledgements

=over

=item Thermeon.

=item Piers Cawley.

=item Gareth Kirwan.

=back

=head1 COPYRIGHT

Copyright 2014-2015 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.