如何找到没有对象的方法的源位置?例如,我想找到活动记录的find方法或Machinist gem的make方法的源位置。这些方法通常是在没有任何对象的情况下调用的。
发布于 2013-01-29 06:08:23
require 'active_record'
m=ActiveRecord::Base.method :find
# => #<Method: Class(ActiveRecord::Querying)#find>
m.source_location
# => ["/<snip>/gems/activerecord-3.2.11/lib/active_record/querying.rb", 4]https://stackoverflow.com/questions/14555865
复制相似问题