From c6c5652c31ea850a8f126e301948a068f6bbf588 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Wed, 22 Jul 2026 11:25:49 +0200 Subject: [PATCH] Remove `ruby2_keyword` usage Also a bit easier to understand. --- lib/bootsnap/compile_cache/yaml.rb | 48 ++++++++---------------------- 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/lib/bootsnap/compile_cache/yaml.rb b/lib/bootsnap/compile_cache/yaml.rb index 1ae061f..96a1a62 100644 --- a/lib/bootsnap/compile_cache/yaml.rb +++ b/lib/bootsnap/compile_cache/yaml.rb @@ -226,15 +226,11 @@ def input_to_output(data, _path, kwargs) end module Patch - def load_file(path, *args) + def load_file(path, *unknown_args, **kwargs) return super unless CompileCache::YAML.supported_internal_encoding? - return super if args.size > 1 - - if (kwargs = args.first) - return super unless kwargs.is_a?(Hash) - return super unless (kwargs.keys - CompileCache::YAML.supported_options).empty? - end + return super if unknown_args.size > 1 + return super unless (kwargs.keys - CompileCache::YAML.supported_options).empty? CompileCache::Native.fetch( CompileCache::YAML.cache_dir, @@ -245,17 +241,11 @@ def load_file(path, *args) ) end - ruby2_keywords :load_file if respond_to?(:ruby2_keywords, true) - - def unsafe_load_file(path, *args) + def unsafe_load_file(path, *unknown_args, **kwargs) return super unless CompileCache::YAML.supported_internal_encoding? - return super if args.size > 1 - - if (kwargs = args.first) - return super unless kwargs.is_a?(Hash) - return super unless (kwargs.keys - CompileCache::YAML.supported_options).empty? - end + return super if unknown_args.size > 1 + return super unless (kwargs.keys - CompileCache::YAML.supported_options).empty? CompileCache::Native.fetch( CompileCache::YAML.cache_dir, @@ -265,8 +255,6 @@ def unsafe_load_file(path, *args) kwargs, ) end - - ruby2_keywords :unsafe_load_file if respond_to?(:ruby2_keywords, true) end end @@ -299,15 +287,11 @@ def input_to_output(data, _path, kwargs) end module Patch - def load_file(path, *args) + def load_file(path, *unknown_args, **kwargs) return super unless CompileCache::YAML.supported_internal_encoding? - return super if args.size > 1 - - if (kwargs = args.first) - return super unless kwargs.is_a?(Hash) - return super unless (kwargs.keys - CompileCache::YAML.supported_options).empty? - end + return super if unknown_args.size > 1 + return super unless (kwargs.keys - CompileCache::YAML.supported_options).empty? CompileCache::Native.fetch( CompileCache::YAML.cache_dir, @@ -318,17 +302,11 @@ def load_file(path, *args) ) end - ruby2_keywords :load_file if respond_to?(:ruby2_keywords, true) - - def unsafe_load_file(path, *args) + def unsafe_load_file(path, *unknown_args, **kwargs) return super unless CompileCache::YAML.supported_internal_encoding? - return super if args.size > 1 - - if (kwargs = args.first) - return super unless kwargs.is_a?(Hash) - return super unless (kwargs.keys - CompileCache::YAML.supported_options).empty? - end + return super if unknown_args.size > 1 + return super unless (kwargs.keys - CompileCache::YAML.supported_options).empty? CompileCache::Native.fetch( CompileCache::YAML.cache_dir, @@ -338,8 +316,6 @@ def unsafe_load_file(path, *args) kwargs, ) end - - ruby2_keywords :unsafe_load_file if respond_to?(:ruby2_keywords, true) end end end