Skip to content

Instantly share code, notes, and snippets.

@kyanny
Created March 7, 2013 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyanny/6d3113bf8a403f3885b1 to your computer and use it in GitHub Desktop.
Save kyanny/6d3113bf8a403f3885b1 to your computer and use it in GitHub Desktop.
require 'ostruct'
class MyProxyClass
def initialize(env)
@env = OpenStruct.new(env)
end
def method_missing(method, *args)
@env.send(method) || @env.send(method.upcase)
end
end
env_proxy = MyProxyClass.new(ENV)
p env_proxy.USER
p env_proxy.user
p env_proxy.unknown_environment_variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment