包括方法假設我有這個使用紅寶石
module Command
extend ActiveSupport::Concern
included do
@path ||= File.join("#{file_path}", "some_file")
end
def file_path
File.expand_path("some_other_file")
end
...
當包含模塊,我得到undefined local variable or method file_path
。那麼有沒有辦法,使file_path
方法在包含模塊時被識別? (當然沒有把file_path
在included
法)
['Module#included'](http://ruby-doc.org/core-2.0.0/Module.html#method-i-included)沒有佔用block ..在哪裏找到代碼? –