Grooming.

This commit is contained in:
Luka Vandervelden 2019-10-28 06:06:18 +01:00
parent c80360e380
commit 36829e8664
2 changed files with 11 additions and 8 deletions

View File

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

View File

@ -441,6 +441,16 @@ class Service
def get_default_provider(token) : String?
@environment.get_provider(token) || Environment.root.get_provider(token)
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