Not sure if this is the best way to do things. But I want to include modules into a class based on the rails environment.

First I used the rails config store, Configurator.

module MyApp
  class Application < Rails::Application
    # ...
    config.provider = :NullProvider

The above config can be overridden in the environment config file. NullProvider, would just be a noop implementation.

Now, using this is a combo using send, accessing the config value, and getting the class from the symbol.

class MyClass
  MyClass.__send__(:include, Kernel.const_get(::MyApp::Application.config.provider))

Put that where ever you’re include would normally go.

Would love to know if this is something crazy or a good way to do things.