Is it just me or is the following not very readable?
Figaro.env.stripe_api_key
As compared to something like
config.stripe_api_key
I think it would be nice if Figaro had an easy way to change the name or method of accessing the env variables. You can't just do
config = Figaro.env
So as a workaround you can do something like this in the config/initializers/figaro.rb
#Rename Figaro to be something meaningful.
module Config
extend self
def respond_to?(method, *)
Figaro::ENV.respond_to?(method)
end
private
def method_missing(method, *)
Figaro::ENV.send(method)
end
end
#Now you can access the value via
Config.stripe_api_key
Is this the best/easiest way to have a nice readable way to access the env variables?
Is it just me or is the following not very readable?
As compared to something like
I think it would be nice if Figaro had an easy way to change the name or method of accessing the env variables. You can't just do
So as a workaround you can do something like this in the config/initializers/figaro.rb
Is this the best/easiest way to have a nice readable way to access the env variables?