Use #filter_map instead of #collect + #compact

This commit is contained in:
David Heinemeier Hansson
2025-05-09 21:30:33 +02:00
parent 9d5a534ef8
commit fb82d04aaf

View File

@@ -215,9 +215,9 @@ class Kamal::Configuration::Accessory
def extract_hosts_from_config_with_tag(tag) def extract_hosts_from_config_with_tag(tag)
if (servers_with_roles = config.raw_config.servers).is_a?(Hash) if (servers_with_roles = config.raw_config.servers).is_a?(Hash)
servers_with_roles.flat_map do |role, servers_in_role| servers_with_roles.flat_map do |role, servers_in_role|
servers_in_role.collect do |host| servers_in_role.filter_map do |host|
host.keys.first if host.is_a?(Hash) && host.values.first.include?(tag) host.keys.first if host.is_a?(Hash) && host.values.first.include?(tag)
end.compact end
end end
end end
end end