Note: #constantize is here just for back compatibility with other libraries.
It's much better to use the plain #const_get because it will use the current context.
module Dry
class Inflector
VERSION = "0.1.0"
const_get("VERSION") #=> "0.1.0"
Object.const_get("VERSION") #=> NameError: uninitialized constant VERSION
inflector.constantize("VERSION") #=> Don't work either, because uses Object.const_get
end
end
I have simplified constantize to just a
Object.const_get
.Related: https://github.com/dry-rb/dry-inflector/issues/5#issuecomment-344602652
Note: #constantize is here just for back compatibility with other libraries. It's much better to use the plain #const_get because it will use the current context.