Skip to content

Commit 9e4f22b

Browse files
committed
tinycache: Remove Ruby 2.6 workarounds
1 parent ff6ce2f commit 9e4f22b

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

lib/matrix_sdk/util/tinycache.rb

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,24 +76,18 @@ def build_cache_methods(method_name, cache_key: default_cache_key, cache_level:
7676
define_method(method_names[:with_cache]) do |*args|
7777
tinycache_adapter.fetch(__send__(method_names[:cache_key], *args), expires_in: expires_in) do
7878
named = args.delete_at(-1) if args.last.is_a? Hash
79+
named ||= {}
7980

80-
if named
81-
__send__(method_names[:without_cache], *args, **named)
82-
else
83-
__send__(method_names[:without_cache], *args)
84-
end
81+
__send__(method_names[:without_cache], *args, **named)
8582
end
8683
end
8784

8885
define_method(method_names[:without_cache]) do |*args|
8986
orig = method(method_name).super_method
9087
named = args.delete_at(-1) if args.last.is_a? Hash
88+
named ||= {}
9189

92-
if named
93-
orig.call(*args, **named)
94-
else
95-
orig.call(*args)
96-
end
90+
orig.call(*args, **named)
9791
end
9892

9993
define_method(method_names[:clear_cache]) do |*args|

0 commit comments

Comments
 (0)