perf(api particulier): use filter_map instead of map.compact

https://docs.rubocop.org/rubocop-performance/cops_performance.html#performancemapcompact
This commit is contained in:
François Vantomme 2021-11-30 12:53:23 +01:00 committed by simon lehericey
parent a24cf18c9d
commit cfb8c184fe

View file

@ -7,8 +7,7 @@ module APIParticulier
def available_sources
@procedure.api_particulier_scopes
.map { |provider_and_scope| raw_scopes[provider_and_scope] }
.compact
.filter_map { |provider_and_scope| raw_scopes[provider_and_scope] }
.map { |provider, scope| extract_sources(provider, scope) }
.reduce({}) { |acc, el| acc.deep_merge(el) { |_, this_val, other_val| this_val + other_val } }
end