active_memoize 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/active_memoize/cache.rb +2 -2
- data/lib/active_memoize/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23ee780fe6d6ebdc2bd6ba86a1c5dbf3260c3fda30ff914857882fa7da312a80
|
4
|
+
data.tar.gz: 42ce906344c29813277144097d37db2da148ce9ad123d6823a0e3461c1e75c1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da2294d42e443ff10c146158373d7018cdc476328a05fef5394b68417227578772ab91f930b785baf3eb22aa3ad6cc802734c12faa9b2343fabef93ca90daaa2
|
7
|
+
data.tar.gz: 1090efd7a92f53aaa7846bc8ba4ac8cf6835ee651ddb99b612bfc8e230fffa19510c8dfe2e12bee740f62c8721f561f97552e74cdce190755e5e18fbc366a95c
|
data/README.md
CHANGED
data/lib/active_memoize/cache.rb
CHANGED
@@ -53,9 +53,9 @@ module ActiveMemoize
|
|
53
53
|
@cache.merge!(hash)
|
54
54
|
end
|
55
55
|
|
56
|
-
def memoize(&block)
|
56
|
+
def memoize(method_name = nil, &block)
|
57
57
|
method_locals = caller_locals(block)
|
58
|
-
method_name
|
58
|
+
method_name ||= caller_method
|
59
59
|
method_name = "#{caller_method}:#{method_locals}" unless method_locals.nil?
|
60
60
|
|
61
61
|
return @cache[method_name] if @cache.key?(method_name)
|