Grooming.

master
Luka Vandervelden 2019-10-28 06:06:18 +01:00
parent a29db9142a
commit 00f9a2b228
2 changed files with 11 additions and 8 deletions

View File

@ -116,14 +116,7 @@ class GenConfig::Context
service.provides.each do |provider_data| service.provides.each do |provider_data|
token = provider_data.token token = provider_data.token
# FIXME: definitely unreadable consumers[token] = service.get_consumers(token).map &.to_genconfig
consumers[token] = Service.all
.select(
&.providers.select do |t, provider|
t == token && service.is_id?(provider)
end
.size.>(0))
.map &.to_genconfig
end end
options["consumers"] = consumers options["consumers"] = consumers
end end

View File

@ -441,6 +441,16 @@ class Service
def get_default_provider(token) : String? def get_default_provider(token) : String?
@environment.get_provider(token) || Environment.root.get_provider(token) @environment.get_provider(token) || Environment.root.get_provider(token)
end end
def consumes?(token, origin)
providers.select do |_token, provider|
token == _token && origin.is_id?(provider)
end.size > 0
end
def get_consumers(token)
Service.all.select(&.consumes?(token, self))
end
end end