Created
November 21, 2012 11:28
-
-
Save tooky/4124434 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Context | |
def the(key, value) | |
context[key] = value | |
end | |
def method_missing(method, *args, &block) | |
key = extract_key(method) | |
if key | |
context.fetch(key.to_sym) | |
else | |
super | |
end | |
end | |
private | |
def context | |
@context ||= {} | |
end | |
def extract_key(method) | |
method[/^the_(.+)/, 1] | |
end | |
end | |
World(Context) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Or rather...