Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dry::Configurable::TestInterface::reset_config won't reset nested settings #27

Merged
merged 1 commit into from
Feb 20, 2017

Conversation

spectator
Copy link
Contributor

Hi,

This PR adds falling test to demonstrate the issue with Dry::Configurable::TestInterface::rest_config that won't reset nested settings.

When configurable has nested setting, they won't reset after calling
`reset_config`.
@GustavoCaso
Copy link
Member

@spectator I have been looking and it looks when using configure with nested keys it will not store the default value instead it store the config object with the value from the configure block.

[#<Dry::Configurable::Config::Value:0x007fc6099b8120 @name=:dsn, @value=nil, @processor=#<Proc:0x007fc60b0e2c10@/Users/morty/dev/gems/dry-configurable/lib/dry/configurable/config.rb:5 (lambda)>>, #<Dry::Configurable::Config::Value:0x007fc609a23510 @name=:pool, @value=#<#<Class:0x007fc60aa230f0>:0x007fc60aa21fc0 @config={:size=>5}>, @processor=#<Proc:0x007fc60b0e2c10@/Users/morty/dev/gems/dry-configurable/lib/dry/configurable/config.rb:5 (lambda)>>]

I do not have much experience with this library, but I think maybe there will need to have some changes regarding the internal structure and how they handle nested attributes.

@AMHOL I'll be happy to give a hand with this one. I was thinking instead of returning the actual proc when calling config

#<#<Class:0x007fc60b2f2708>:0x007fc60b2f23e8 @config={:dsn=>"sqlite:memory", :pool=>#<#<Class:0x007fc60aa230f0>:0x007fc60aa21fc0 @config={:size=>5}>}>

We could return an OpenStruct which will allow the user to access with the intended interface:
klass.config.pool.size. That wey we could store the actual default value for the nested attributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants