From: Eric Mahurin Date: 2005-07-13T01:01:36+09:00 Subject: Re: Determining if initialize is defined in child class --- Jim Freeze wrote: > Hi > > I am looking for a method that will tell me if a method > is defined in a child class. The problem is when looking > at child classes for with the parent has the method in > question defined. > > class C > private_method_defined?(:fred) #=> false > private_method_defined?(:initialize) #=> true > end > > Is there some method that will return false for the above > initialize method: > > class C > method_defined_in_this_class?(fred:) #=> false > method_defined_in_this_class?(:initialize) #=> false > def fred; end > method_defined_in_this_class?(fred:) #=> true > end > > Ultimately I want to be able to do the following: > > class Parent > def initialize; end > end > > class Child < Parent > method_defined_in_this_class?(:initialize) #=> false > end How about this: private_instance_methods(false).include?("initialize") ____________________________________________________ Sell on Yahoo! Auctions � no fees. Bid on great items. http://auctions.yahoo.com/