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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 825d56d2f91c7f4e6410adb6a0954bb30e011633b1802dc37ce6ca619ecf4b4e
4
- data.tar.gz: 11ce236a5ba5172b378c449b4c291ede92ec9c88d32b483d54f014ca76ded3a8
3
+ metadata.gz: 23ee780fe6d6ebdc2bd6ba86a1c5dbf3260c3fda30ff914857882fa7da312a80
4
+ data.tar.gz: 42ce906344c29813277144097d37db2da148ce9ad123d6823a0e3461c1e75c1e
5
5
  SHA512:
6
- metadata.gz: 119719ab6e15811eaaada9272bedfbb369c062fe06c762ce9b9ac3b71c17b66e9df49ce2e56b439eec93f86b67312fa3c8c151290f8cfc2a2ae0f454e97b4e6c
7
- data.tar.gz: fec75cbb9dc8248017f58fc43b58ad261a86f42d9e4f1dd0962c6f210b1948a259924fc2ef9ac64b2fa5e0488748b90b7901d5549d2194b24f432f07b27206c8
6
+ metadata.gz: da2294d42e443ff10c146158373d7018cdc476328a05fef5394b68417227578772ab91f930b785baf3eb22aa3ad6cc802734c12faa9b2343fabef93ca90daaa2
7
+ data.tar.gz: 1090efd7a92f53aaa7846bc8ba4ac8cf6835ee651ddb99b612bfc8e230fffa19510c8dfe2e12bee740f62c8721f561f97552e74cdce190755e5e18fbc366a95c
data/README.md CHANGED
@@ -35,6 +35,12 @@ class Movies
35
35
  @cache ||= ActiveMemoize::Cache.new
36
36
  end
37
37
 
38
+ def all
39
+ cache.memoize('custom_cache_key') do
40
+ HTTP.get("http://movies.com/all")
41
+ end
42
+ end
43
+
38
44
  def random
39
45
  cache['random'] ||= HTTP.get('http://movies.com/any')
40
46
  end
@@ -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 = caller_method
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveMemoize
4
- VERSION ||= '1.0.3'
4
+ VERSION ||= '1.1.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_memoize
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez