def poor_mans_method_owner(method, method_name)
      # A Method object has no :owner method, but we can infer it's owner from the result of it's
      # :to_s method. Examples:
      # 37.method(:rdiv).to_s => "#<Method: Fixnum#rdiv>"
      # 37.method(:ceil).to_s => "#<Method: Fixnum(Integer)#ceil>"
      # 37.method(:prec).to_s => "#<Method: Fixnum(Precision)#prec>"
      # obj.method(:singleton_method).to_s => "#<Method: #<Object:0x5673b8>.singleton_method>"
      # For a nested module: "#<Method: Module1::ClassName(Module1::Module2::Module3)#method>"

      build_ancestor_regexp_map
      @ancestors.each do |ancestor|
        return ancestor if method.to_s =~ @ancestor_regexp_map[ancestor]
      end
      nil
    end
def poor_mans_method_owner(method, method_name)
      # A Method object has no :owner method, but we can infer it's owner from the result of it's
      # :to_s method. Examples:
      # 37.method(:rdiv).to_s => "#<Method: Fixnum#rdiv>"
      # 37.method(:ceil).to_s => "#<Method: Fixnum(Integer)#ceil>"
      # 37.method(:prec).to_s => "#<Method: Fixnum(Precision)#prec>"
      # obj.method(:singleton_method).to_s => "#<Method: #<Object:0x5673b8>.singleton_method>"
      # For a nested module: "#<Method: Module1::ClassName(Module1::Module2::Module3)#method>"

      build_ancestor_regexp_map
      @ancestors.each do |ancestor|
        return ancestor if method.to_s =~ @ancestor_regexp_map[ancestor]
      end
      nil
    end
Ruby 1.8.6 has no Method#owner method, this is a poor man's replacement. It has horrible
 performance and may break for other ruby implementations than MRI.