-
-
Save kyanny/6d3113bf8a403f3885b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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