Jeff Schwab
5/19/2006 3:04:00 PM
Tassilo Horn wrote:
> ts <decoux@moulon.inra.fr> writes:
>
>>>>>>> "T" == Tassilo Horn <heimdall@uni-koblenz.de> writes:
>> Just write it
>>
>> T> ,----
>> T> | require 'qdbm'
>> T> | db_backend = QDBM.class
>>
>> db_backend = QDBM
>
> Ah, great. Unfortunately GDBM.open() and Depot.open() (that's the QDBM
> thing) have different parameter list langths, so I cannot work arround
> the if-statement anyway. :-(
Having two calls to methods with the same name, but different recipients
and parameter lists, is probably forgivable. :) Of course, you
shouldn't have to duplicate the body of the open-blocks.
,----
| def foo(dbm)
| ...
| end
|
| begin
| require 'qdbm'
| Depot.open(...) { |dbm| foo(dbm) }
| rescue LoadError
| require 'gdbm'
| GDBM.open(...) { |dbm| foo(dbm) }
| end
`----