We are running into a scenario where several different key names would resolve to the same namespace. Specifically, we’re resolving different “flows” with different customers and their unique slugs are the container namespaces. So multiple customers will resolve to the same “flow” we’re outputting in the container.
We are resolving with code that looks a lot like this:
[name1, name2].each do |name|
namespace name do
register(:key1) { "key" }
end
end
Which is obviously better than:
namespace :name1 do
register(:key1) { "key" }
end
namespace :name2 do
register(:key1) { "key" }
end
But I think this is a reasonable use case that dry-container should handle, I personally like the factorybot syntax for aliases if we’re looking for examples:
namespace :name1, aliases: [:name2, name3] do
register(:key1) { "key" }
end
container.resolve('name2.key1')
=> "key"
I tried doing a custom resolver to handle this, but it gets gross pretty quickly when the alias is in an intermediary namespace.