Alexey Poimtsev
Alexey Poimtsev

Reputation: 2847

How to detect gem usage in rails project?

I'd like to enable support for Inherited Resources gem in Opinio gem, but I need to detect if Inherited Resources is used in the project.

I've looked at the docs for Bundler to find something about gem usage detection, but I've found nothing. Could you recommend me something?

Upvotes: 0

Views: 199

Answers (1)

deefour
deefour

Reputation: 35370

You can test if the InheritedResources gem's module exists.

begin
  Module.const_get('InheritedResources')
  # made it here? InheritedResources is included
rescue NameError => e
  # InheritedResources is not included
end

Upvotes: 1

Related Questions