Created
April 23, 2011 16:59
-
-
Save neilmock/938772 to your computer and use it in GitHub Desktop.
denvar, envars in your data store.
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
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 |
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
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