In my app, I have
VeryUniqueModule::Foo
# and…
VeryUniqueModule::Bar
Foo
and Bar
are each for a different service
You might try this:
VeryUniqueModule.const_get('::VeryUniqueModule::' + @relevant_object.service)
And if that doesn't work, you could try bypassing service_api
and doing this wherever you need A_CONSTANT
:
Object.const_get('::VeryUniqueModule::' + @relevant_object.service + '::A_CONSTANT')
Note the ::
before VeryUniqueModule
. I don't think it's strictly necessary in this case, but it could be useful in that it guarantees Ruby will look for VeryUniqueModule
in the global namespace and not inside some other module.