Is it possible to remove some of the inherited methods in Ruby? I mean, I can override it, but is there any other way?
Class ABC
end
a = ABC.new
puts a.id
Here, the method id is inherited from Object along with other methods like tap,class,type etc. I want to remove such methods.
Edit: I’m using Ruby 1.8.7
Yes –
undef_method :foowill prevent any calls to the methodfoo(contrasted withremove_method :foo, which removes the method from the child, but still passes through up the inheritance chain).Once again, though, why do you want to remove things like
id?