Skip to content

Instantly share code, notes, and snippets.

@ak47
Created June 5, 2012 22:27
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 ak47/2878529 to your computer and use it in GitHub Desktop.
Save ak47/2878529 to your computer and use it in GitHub Desktop.
module B
def self.included(base)
class << base
attr_accessor :catch
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