Skip to content

Commit f154799

Browse files
rovermicroverbeauby
authored andcommitted
Multi fetch needs the array of keys splatted. (#29)
* Multi fetch needs the array of keys splatted. * Fix tests to match rails multi_cache
1 parent 7bc52e7 commit f154799

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/jsonapi/renderer/cached_resources_processor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def initialize(cache)
1717
def process_resources
1818
[@primary, @included].each do |resources|
1919
cache_hash = cache_key_map(resources)
20-
processed_resources = @cache.fetch_multi(cache_hash.keys) do |key|
20+
processed_resources = @cache.fetch_multi(*cache_hash.keys) do |key|
2121
res, include, fields = cache_hash[key]
2222
json = res.as_jsonapi(include: include, fields: fields).to_json
2323

spec/caching_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def initialize
55
@cache = {}
66
end
77

8-
def fetch_multi(keys)
8+
def fetch_multi(*keys)
99
keys.each_with_object({}) do |k, h|
1010
@cache[k] = yield(k) unless @cache.key?(k)
1111
h[k] = @cache[k]

0 commit comments

Comments
 (0)