Skip to content

Commit a24830c

Browse files
committed
Use instance_variable_set when cache key doesn't exist
1 parent 3a6457a commit a24830c

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

lib/multi_json/options_cache.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ def fetch(type, key, &)
2222
private
2323

2424
def cache_for(type)
25-
instance_variable_get("@#{type}_cache") || begin
26-
reset
27-
instance_variable_get("@#{type}_cache")
28-
end
25+
ivar = "@#{type}_cache"
26+
instance_variable_get(ivar) || instance_variable_set(ivar, {})
2927
end
3028

3129
def write(cache, key)

0 commit comments

Comments
 (0)