29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/jets/aws_services/global_memoist.rb', line 29
def global_memoize(*methods)
const_defined?(:"GlobalMemoist#{self.object_id}") ?
const_get(:"GlobalMemoist#{self.object_id}") : const_set(:"GlobalMemoist#{self.object_id}", Module.new)
mod = const_get(:"GlobalMemoist#{self.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
|