Skip to content

Commit 5c0af38

Browse files
authored
Refactor unit initialization and update dependencies (#380)
1 parent 6f7f268 commit 5c0af38

3 files changed

Lines changed: 594 additions & 110 deletions

File tree

lib/ruby_units/cache.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ def get(key)
2020
# @return [void]
2121
def set(key, value)
2222
key = key.to_unit.units unless key.is_a?(String)
23+
return if should_skip_caching?(key)
24+
2325
data[key] = value
2426
end
2527

@@ -32,5 +34,9 @@ def keys
3234
def clear
3335
@data = {}
3436
end
37+
38+
def should_skip_caching?(key)
39+
keys.include?(key) || key =~ RubyUnits::Unit.special_format_regex
40+
end
3541
end
3642
end

0 commit comments

Comments
 (0)