2015-03-30 31 views
0

我現在正在做一個健康數據標準庫(https://github.com/projectcypress/health-data-standards.git)的開發基礎。在文件lib/health-data-standards/export/helper/scooped_view_helper.rb(https://github.com/projectcypress/health-data-standards/blob/master/lib/health-data-standards/export/helper/scooped_view_helper.rb)的第90行中,調用patient.entries_for_oid。但該方法沒有定義。在紅寶石中,我怎麼知道memoist方法在做什麼?

在Pry環境下,我試着「編輯patient.entries_for_oid」。編輯器中打開memoist/lib中/在線路166 memoist.rb(https://github.com/matthewrudy/memoist/blob/master/lib/memoist.rb)在那裏,我看到了這些代碼:

  module_eval <<-EOS, __FILE__, __LINE__ + 1 
     def #{method_name}(*args) 
      reload = Memoist.extract_reload!(method(#{unmemoized_method.inspect}), args) 

      skip_cache = reload || !(instance_variable_defined?(#{memoized_ivar.inspect}) && #{memoized_ivar} && #{memoized_ivar}.has_key?(args)) 
      set_cache = skip_cache && !frozen? 

      if skip_cache 
      value = #{unmemoized_method}(*args) 
      else 
      value = #{memoized_ivar}[args] 
      end 

      if set_cache 
      #{memoized_ivar} ||= {} 
      #{memoized_ivar}[args] = value 
      end 

      value 
     end 
     EOS 
    end 

但它沒有什麼意義,有什麼patient.entries_for_oid確實。

任何人都知道嗎?

由於

回答

0

的方法是definedRecord模型類。這樣的類的一個實例被傳遞給你的助手中的entries_for_data_criteria方法。

您不會簡單地看到實際的方法源,因爲作者選擇使用可用於包裝任意方法來擴展其行爲(在本例中爲緩存,或更精確地說是存儲)的gem。

+0

那麼我怎麼能調試'方法'?現在它濾除了我的一個重要記錄。 – tlikeit 2015-03-30 22:50:55

相關問題