Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Gracefully Downgrading Behavior

by gaal (Parson)
on May 10, 2007 at 09:15 UTC ( #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.


Comment on Re: Gracefully Downgrading Behavior
Select or Download Code
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? :)

    Cheers,
    Ovid

    New address of my CGI Course.

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://614580]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2014-09-03 07:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (35 votes), past polls