From cb5570918869d967bbafa27a19381cca28a41115 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Fri, 24 Nov 2023 13:37:00 +0100 Subject: [PATCH 1/2] Refs #36849 - Use kwargs in method_missing definition --- app/models/host.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/models/host.rb b/app/models/host.rb index 12d7d98593e..ec5f43d07f1 100644 --- a/app/models/host.rb +++ b/app/models/host.rb @@ -1,18 +1,16 @@ module Host - def self.method_missing(method, *args, &block) + def self.method_missing(method, *args, **kwargs, &block) type = "Host::Managed" case method.to_s when /create/, 'new' - if args.empty? || args[0].nil? # got no parameters - # set the default type - args = [{:type => type}] - else # got some parameters - args[0][:type] ||= type # adds the type if it doesn't exists - type = args[0][:type] # stores the type for later usage. + if kwargs.key?(:type) + type = kwargs[:type] + else + kwargs[:type] = type end end if type.constantize.respond_to?(method, true) - type.constantize.send(method, *args, &block) + type.constantize.send(method, *args, **kwargs, &block) else super end From 3f884e3307a485ba887574b30ef093806454aa58 Mon Sep 17 00:00:00 2001 From: Oleh Fedorenko Date: Fri, 10 Nov 2023 17:53:06 +0000 Subject: [PATCH 2/2] Fixes #36849 - Run GHA on Ruby 3.0 --- .github/matrix.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/matrix.json b/.github/matrix.json index 81e37ac5f94..f15a18dd692 100644 --- a/.github/matrix.json +++ b/.github/matrix.json @@ -1,5 +1,5 @@ { "postgresql": ["12"], - "ruby": ["2.7"], + "ruby": ["2.7", "3.0"], "node": ["14"] }