Skip to content

Instantly share code, notes, and snippets.

@fronx
Created January 4, 2010 16:00
Show Gist options
  • Select an option

  • Save fronx/268611 to your computer and use it in GitHub Desktop.

Select an option

Save fronx/268611 to your computer and use it in GitHub Desktop.
class Object
def bury(class_or_module_name)
Object.instance_eval { remove_const class_or_module_name.to_sym }
end
end
# Example for class self inheritance
class Abc
def foo
"foo"
end
end
class Abc < bury(:Abc)
def foo
puts super
end
end
Abc.new.foo
# Example for module self inheritance
module Xyz
def bar
"bar"
end
end
BuriedXyz = bury(:Xyz)
module Xyz
include BuriedXyz
def bar
puts super
end
end
class XyzTest
include Xyz
end
XyzTest.new.bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment