Skip to content

Instantly share code, notes, and snippets.

@edvardm
Last active December 18, 2015 21:48
Show Gist options
  • Save edvardm/5849494 to your computer and use it in GitHub Desktop.
Save edvardm/5849494 to your computer and use it in GitHub Desktop.
class Hash
class Mediator < BasicObject
def initialize(hash, *syms)
@h = hash
@syms = syms
end
def method_missing(name, *args)
@h.has_key?(name) ? @h[name] : super
end
def mediate(&block)
instance_eval(&block)
end
end
def pick(*syms, &block)
Mediator.new(self, *syms).mediate(&block)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment