Cannot find origin object in Rails project

百般思念 提交于 2021-02-04 21:45:45

问题


I just inherited a Rails app for a new gig. Thee code is insane and heavily buried in gem logic so VERY difficult and un-rails-like to navigate. I am having a terrible time tracking down the following logic.

    @navigator ||= BitPlayer::Navigator.new(current_participant)

I have searched everywhere (in app as well as gem dirs) for a BitPlayer class/object as well as Navigator and cannot find a thing. I am thinking I don't understand the fundamental composition of the line.

Can someone point me in the right direction where to look for this? I desperately need to find that "Navigator.new" method!


回答1:


You could try Method#source_location. For example:

Nokogiri::HTML.method(:fragment).source_location
# ["/Users/mu/.../gems/nokogiri-1.10.10/lib/nokogiri/html.rb", 29] 

And then looking line 29 of the file we see:

def fragment string, encoding = nil

So start with:

BitPlayer::Navigator.method(:initialize).source_location


来源:https://stackoverflow.com/questions/63974323/cannot-find-origin-object-in-rails-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!