gpt4 book ai didi

ruby - 我怎样才能找出猴子修补方法的文件/ gem ?

转载 作者:太空宇宙 更新时间:2023-11-03 17:05:31 26 4
gpt4 key购买 nike

我的依赖列表中有一个 Gem,它是 Monkey Patching to_json on String。

我怎么知道这个猴子补丁发生在哪里?

最佳答案

使用source_location .

Returns the Ruby source filename and line number containing this method or nil if this method was not defined in Ruby (i.e. native)

$ cat monkey.rb
class String
def reverse
""
end
end

p String.instance_method(:reverse).source_location
$ ruby monkey.rb
["monkey.rb", 2]

关于ruby - 我怎样才能找出猴子修补方法的文件/ gem ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13895725/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com