Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/matrix.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"postgresql": ["12"],
"ruby": ["2.7"],
"ruby": ["2.7", "3.0"],
"node": ["14"]
}
14 changes: 6 additions & 8 deletions app/models/host.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down