Ara.T.Howard <Ara.T.Howard <at> noaa.gov> writes:

> i don't know a direct way, but maybe:
> 
>    harp:~ > cat a.rb
>    class Object
>      def defines method
>        singleton_class = class << self; self; end
>        ([singleton_class] + self.class.ancestors).reverse.each do |a|
>          return a if a.instance_methods.include? method
>        end
>        return nil
>      end
>      alias defines? defines
>    end

If you want to get at the class reported by Method#inspect, you shouldn't
reverse the ancestors list. As a consequence, you have to treat singleton
methods special. If you also want to support private singleton methods, it gets
really nasty. If someone needs this (support for private singleton methods), I
can show you the code.

Regards,
Pit