0

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?

Alex
  • 9,313
  • 1
  • 39
  • 44
Alexey Poimtsev
  • 2,845
  • 3
  • 35
  • 63
  • Probably best to include a declaration in your gemspec with a ~> version ? e.g. `s.add_dependency("inherited_resources", "~> 1.3")`. Or you could try to require, and rescue from a `LoadError` – Thong Kuah Jul 10 '12 at 22:44

1 Answers1

1

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
deefour
  • 34,974
  • 7
  • 97
  • 90