lib/active_memoize/cache.rb in active_memoize-1.0.2 vs lib/active_memoize/cache.rb in active_memoize-1.0.3
- old
+ new
@@ -52,10 +52,13 @@
def merge!(hash)
@cache.merge!(hash)
end
def memoize(&block)
- method_name = [caller_method, caller_locals(block)].compact.join(':')
+ method_locals = caller_locals(block)
+ method_name = caller_method
+ method_name = "#{caller_method}:#{method_locals}" unless method_locals.nil?
+
return @cache[method_name] if @cache.key?(method_name)
@cache[method_name] = yield(block)
end