Skip to content

Instantly share code, notes, and snippets.

@nilo

nilo/rb Secret

Created September 11, 2015 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nilo/fb1ad744f226244c5673 to your computer and use it in GitHub Desktop.
Save nilo/fb1ad744f226244c5673 to your computer and use it in GitHub Desktop.
class Module
def f(name)
b = ("_" + name.to_s).to_sym
alias_method b, name
define_method(name) do |*args|
@mc ||= {}
@mc[name] ||= {}
@mc[name][args] ||= self.send b, *args
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment