From: Trans Date: 2006-10-26T10:00:12+09:00 Subject: Re: Calling functions in a child class Brian Schlect wrote: > I have a class: > > class alpha > def test_method > puts "test method" > end > > def get_methods > puts alpha.methods > end > end > > running "get_methods" here will return a long list of methods including > test_method. But, I also have this class: > > class bravo < alpha > def another_test_method > end > end > > i want to be able to call get_methods in the parent class and have it > return the functions of the child class as well. so in this example: > > test_obj = bravo.new > bravo.get_methods > > would return all methods including > > test_method > another_test_method > > any ideas? That's an expensive operation. Something along the lines of: ObjectSpace.each(alpha) { |k| p k.get_methods } In fact, that's so exepnsive you may want to reconsider what you're trying to do here. T.