[dry-container] Resolve from another namespace


#1

Hey there,

we’ve been using dry-container for a while now and it’s great. But we’ve stumbled into a “issue” which I would like to discuss and see if it’s possible to get it working. We got the following situation:

...
namespace('config') do
  register('database_url') { ENV.fetch('DATABASE_URL') }
end

namespace('databases') do
  register('postgres', memoize: true) { Sequel.connect(resolve('config.database_url')) }
end
...

Now when we run this the config.database_url is resolved to databases.config.database_url instead. Is there a possible way to get the database_url from the right namespace without the nested databases?

When I look up the namespace dsl I noticed the resolve method always namespaces a key. So I assume there is no work around.


#2

I’ve created a PR to solve my issue: https://github.com/dry-rb/dry-container/pull/55