Skip to content

Instantly share code, notes, and snippets.

@pavlo-vavruk
Last active August 5, 2016 12:48
Show Gist options
  • Save pavlo-vavruk/da367ae34230ee58e7d2fed46be46114 to your computer and use it in GitHub Desktop.
Save pavlo-vavruk/da367ae34230ee58e7d2fed46be46114 to your computer and use it in GitHub Desktop.
ENV settings proxy.
class Settings
@@envs = []
def self.method_missing(name, *args)
@@envs << name.upcase.to_s
return ENV["#{@@envs.join('_')}"] || args.first unless args.empty?
self
end
end
Settings.s3.rows('tmp').inspect
@pavlo-vavruk
Copy link
Author

Usage:

ruby settings_env_proxy.rb
=> "tmp"
S3_ROWS='env_value' ruby settings_env_proxy.rb
=> "env_value"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment