Checking for other extensions and gems

I’m writing an extension that depends on shards. I’d like to check for
it and raise a useful error message when my extension is initialized.

Any suggestions as to the best way to do that?

-Chris

raise ‘blah requires the installation of the Shards extension’ unless
defined?(ShardsExtension)

Check for the existence of the Shards module:

raise “The Shards extension is required and must be loaded first!”
unless defined?(Shards)

Sean

And be sure that your extension loads after shards…

/AITOR

Aitor Garay-Romero wrote:

And be sure that your extension loads after shards....

What is the mechanism for forcing extension load order?

-Chris

Also, in environment.rb, you can add this:

config.extensions = [ :shards, :all ]

That will load shards first, then any other extensions. The :all is a
placeholder so you can load extensions at the end, too.

Sean

Search this list, it has been discussed in the past.

Fast solution: they load in “alphabetic order”, so “00_extension”
will
load before “01_extension”.

/AITOR