Skip to content

Instantly share code, notes, and snippets.

@hynkle
Created August 11, 2011 03:59
Show Gist options
  • Save hynkle/1138876 to your computer and use it in GitHub Desktop.
Save hynkle/1138876 to your computer and use it in GitHub Desktop.
undef_method metaprogramming confusion
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