Remove all class methods via remove_method

Hi,

how do I remove all my class methods like in the following example? –

class Parent
class << self
def class_stuff
puts “Stuff from my class”
end
end
end

class Child < Parent

remove all the class methods;

should be done automatically with "…methods.each { |m|

remove_method(m) }"-like construct
end

Many thanks in advance.

dodeantn,
This will do it but I would prefer a better way…

class Parent
(class << self; self; end).send(:remove_method, :class_stuff)
end

Please remember that with great power comes great responsibility… :slight_smile:
messing with class methods is a real pain in 1.8 but maybe I am missing
the boat…

hth

ilan

dodeantn wrote:

Hi,

how do I remove all my class methods like in the following example? –

class Parent
class << self
def class_stuff
puts “Stuff from my class”
end
end
end

class Child < Parent

remove all the class methods;

should be done automatically with "…methods.each { |m|

remove_method(m) }"-like construct
end

Many thanks in advance.