Created
August 11, 2011 03:59
-
-
Save hynkle/1138876 to your computer and use it in GitHub Desktop.
undef_method metaprogramming confusion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
def foo | |
puts "foo" | |
end | |
end | |
class Bar < Foo | |
undef_method :foo | |
end | |
Foo.new.foo #=> prints "foo" | |
Bar.new.foo #=> raises NoMethodError | |
class Baz | |
def self.baz | |
puts "baz" | |
end | |
end | |
class Quux < Baz | |
# ...??? how do I undefine self.baz? | |
end | |
Baz.baz #=> prints "baz" | |
Quux.baz #=> I would like this to raise a NoMethodError |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment