Skip to content

Instantly share code, notes, and snippets.

@neilmock
Created April 23, 2011 16:59
Show Gist options
  • Save neilmock/938772 to your computer and use it in GitHub Desktop.
Save neilmock/938772 to your computer and use it in GitHub Desktop.
denvar, envars in your data store.
module Denvar
def self.lookup key
@lookup.call key
end
def self.activate! &block
@lookup = block
class << ENV
alias :orig_lookup :[]
def [] key
orig_lookup(key) || Denvar.lookup(key)
end
end
end
end
store = {"BUNNY" => "HOP"}
Denvar.activate! do |key|
store[key]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment