[英]In ruby, how do I know what a memoist method is doing?
我现在正在基于health-data-standards库( 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 。 但是该方法未定义。
在Pry环境下,我尝试“编辑Patient.entries_for_oid”。 编辑器在第166行打开memoist / lib / 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
但这没有意义,耐心.entries_for_oid到底是做什么的。
有人知道吗?
谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.