When declaring a dry-system
module, the inherited dry-container
(DSL) setting
allow to declare
some new settings
entries, but after the call to configure
all other settings
calls, properly add
new entries into the @settings
array, but they aren’t resolved.
example :
module Cube
class Container < Dry::System::Container
env = ENV.fetch('ENV', ENV.fetch('RACK_ENV', 'development')).to_sym
setting :env, env
setting :toto, "toto"
# after this call, no new `setting` entry will be returned
# by a call to <container>.config.<entry>
configure do |config|
config.name = :cube
config.auto_register = %w[components]
end
setting :tutu, "tutu"
end
end
Before the call to configure
Cube::Container.config['env']
=> :development
Cube::Container.config.toto
=> "toto"
but
Cube::Container.config['tutu']
=> +tutu+ is not a setting name
I found this interesting and with some added benefits as it allow to have some settings freezing
without having to change dry-container
configurable options that are tied to dry-system
logic, just
for the purpose of adding new `attributes/settings’ to the root Container.
Is this a ‘feature’ valuable enough to merit some note, or if this is a bug it is better not to count on it