Can I find the file / linenumber where the method was defined?

Duplicate: How to Find Where in Runtime a Ruby Method is Defined


With a given object, can you find out where each method was defined?
0


source to share


1 answer


After that it will be quite difficult, but you can use the hook method to observe the line numbers where the method is defined.



class X < Object

  def X.method_added(symbol)
    puts "adding method #{symbol} to class X from #{caller(0)}"
  end

end


class X
  def a_method
  end
end

      

0


source







All Articles