Skip to content

Instantly share code, notes, and snippets.

@58bits
Created June 6, 2012 04: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 58bits/2879853 to your computer and use it in GitHub Desktop.
Save 58bits/2879853 to your computer and use it in GitHub Desktop.
module B
@@catch
def self.included(base)
class << base
def catch=(hsh)
@@catch = hsh
end
def catch
@@catch
end
def acts_as_catchall(hsh)
self.catch = hsh
end
end
end
def method_missing(meth, *args)
if s = self.class.catch[meth]
return s
else
super
end
end
end
class A
include B
acts_as_catchall :cat => 'meow'
end
class C < A
end
a = C.new
p a.cat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment