34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/jets/aws_services/global_memoist.rb', line 34
def global_memoize(*methods)
const_defined?(:"GlobalMemoist#{object_id}") ?
const_get(:"GlobalMemoist#{object_id}") : const_set(:"GlobalMemoist#{object_id}", Module.new)
mod = const_get(:"GlobalMemoist#{object_id}")
mod.class_eval do
methods.each do |method|
define_method(method) do |skip_cache = false|
$__memo_methods ||= {}
if $__memo_methods.include?(method) && !skip_cache
$__memo_methods[method]
else
$__memo_methods[method] = super()
end
end
end
end
prepend mod
end
|