Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Gracefully Downgrading Behavior

by gaal (Parson)
on May 10, 2007 at 09:15 UTC ( [id://614580] : note . print w/replies, xml ) Need Help??

in reply to Gracefully Downgrading Behavior

(Here be plugs.)

When there are several providers of the functionality that have compatible APIs, you can use Best. With modules that just export functions, you simply replace the use line:

use YAML; # This module is slow! # So if you want to try a faster one first: use Best qw(YAML::Syck YAML); print Dump({ some => 'hash' }); # Dumping provided by Best Possible YA +ML module

There's knobs you can use to rewire stuff as in your is_deeply example; and a which function is provided so you can get the name of the module that was actually loaded to write factories with.

use Best qw(OOPishProv AnotherOOPyProv::Serving::As::Fallback); my $obj = Best->which("OOPishProv")->new;

If you're out for less syntax, you might like to try the possibly too-magical Class::TransparentFactory.

Replies are listed 'Best First'.
Re^2: Gracefully Downgrading Behavior
by Ovid (Cardinal) on May 10, 2007 at 09:34 UTC

    So you're recommending that I have users install another module so that they don't need to install another module? :)


    New address of my CGI Course.

      Nah :-) This is addressed in the docs. Basically just stick the tiny file in your lib/, or Inline::Module it (maintainer action; the user need not have I::M installed).