📜  rails 获取源方法 - Ruby 代码示例

📅  最后修改于: 2022-03-11 15:04:46.880000             🧑  作者: Mango

代码示例1
class A
  def foo
  end
end

file, line = A.instance_method(:foo).source_location
# or
file, line = A.new.method(:foo).source_location
puts "Method foo is defined in #{file}, line #{line}"
# => "Method foo is defined in temp.rb, line 2"