On Tue, 31 Oct 2006, Rune Hammersland wrote:

> Hello dear Rubyists.
>
> It was suggested on the IRC channel that I try the ML for this problem ...
>
> While looking at how to undefine a method, I found out that there is a 
> difference in how define_method and the def ... end block works. Example 
> coming up:

<snip>

> # Try to redefine method and call super.
> class Child < Parent

you are not redefining the method here, you are redefining the class.  if you
simply redefine the method it does what you expect:

     harp:~ > cat a.rb
     class Parent
        def lol() puts "P: LOL" end
     end

     class Child < Parent
        def lol() puts "C: LOL" end
     end

     c = Child.new
     Child.class_eval { undef_method :lol }

     class Child  #< Parent
        def lol
          print "LOL: "
          super
        rescue NameError => e
            puts e.to_s
        end
     end

     c.lol


     harp:~ > ruby a.rb
     LOL: superclass method `lol' disabled


regards.

-a
-- 
my religion is very simple.  my religion is kindness. -- the dalai lama