Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to configure Figaro to use a more readable name. #216

Open
dedman opened this issue Oct 6, 2015 · 1 comment
Open

Ability to configure Figaro to use a more readable name. #216

dedman opened this issue Oct 6, 2015 · 1 comment

Comments

@dedman
Copy link

dedman commented Oct 6, 2015

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?

@phillipoertel
Copy link

I built the same, +1 to have this built in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants