From: Loren Segal Date: 2011-01-24T05:09:50+09:00 Subject: [ruby-core:34807] Re: [Ruby 1.9-Bug#4307][Open] include fails after undef_method On 1/23/2011 2:14 PM, Adriano Mitre wrote: > After using #undef_method on a method "inherited" from a mixin, reincluding the mixin should redefine it, but that is not what happens. > This seems like expected behaviour to me. Calling #undef_method inside a class marks that method as uncallable in the class itself. Module inclusion only affects method lookup through the inheritance tree, it doesn't actually copy methods onto the class. Therefore, your Array class is saying: "I will no longer accept method calls to 'foo'". Reincluding (or including another module) does not change the fact that Array is still blocking any calls to 'foo', it only changes the inheritance tree. This is actually well documented: http://rubydoc.info/stdlib/core/1.9.2/Module:undef_method The only way to remove this "undef" is to define the method directly on the class, not through an included module. You can also look at `remove_method` (documented in above link) which will continue to look for a method in the inheritance tree even if removed directly on the class. Note that this would require the original method to be defined on the class itself, not through inclusion (which is not how your example works). The other issue with your example is that re-including an already included module is effectively a noop: module Foo def foo; 42 end end class MyClass include Foo; p ancestors include Foo; p ancestors end # => [MyClass, Foo, Object, Kernel] # => [MyClass, Foo, Object, Kernel]