Remove all class methods via remove_method

D

dodeantn

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.
 
I

Ilan Berci

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.. :)
messing with class methods is a real pain in 1.8 but maybe I am missing
the boat..

hth

ilan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,183
Messages
2,570,968
Members
47,518
Latest member
TobiasAxf

Latest Threads

Top