-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
Add convenience method Dry::Configurable::Settings#replace #117
base: main
Are you sure you want to change the base?
Conversation
Thanks for working on this. It would be great to expose I'm working on integrating dry-configurable into rom-rb's core at the moment and methods like |
No problem! dumb question: can I run rubocop locally to run the linter? |
@skinnyjames sure, |
Fixed up the linting hopefully! If that seems like a good add, I'm happy to add it to the PR. |
@solnic I don't have any clue why it's the way it is, unfortunately! I presume we've simply been preserving some very early API decision without giving it a whole ton of thought. I agree that the set object would be better replaced by the full I'll leave some other thoughts on this PR itself in another comment shortly 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for getting to work on this, @skinnyjames! Really appreciate your effort!
Now, I hope you don't mind, but I've left a few somewhat extensive comments on the code here. We're definitely heading in the right direction, but there are some details we'll want to get right and extra scenarios we should consider before this is a fully resolved new feature.
Anyway, please have a read and let me know if you think anything needs clarifying. Am definitely happy to work with you (and @solnic) as we iterate on this feature!
BTW, @skinnyjames, regarding your original comments in the PR description:
I think the approach you chose in the actual code changes you've made is the right one. 👍🏼 Since |
I'm noticing a weird state issue when invoking the config accessor before merging the settings. klass.setting :database do
setting :dsn, "localhost"
end
other_klass.setting :database do
setting :dsn, "remote"
end
other_klass._settings.merge!(klass._settings)
expect(other_klass.config.database.dsn).to eql("localhost") but this fails. klass.setting :database do
setting :dsn, "localhost"
end
other_klass.setting :database do
setting :dsn, "remote"
end
expect(other_klass.config.database.dsn).to eql("remote")
other_klass._settings.merge!(klass._settings)
expect(other_klass.config.database.dsn).to eql("localhost") For now, I'm not at all sure why that is happening. |
Thanks @skinnyjames — just left you a couple more notes in the previous batch of comments. I'll take a look at the failing specs in the next day or two, I hope. |
No problem. The api should be a little more clear now that "merge" returns settings, and "merge!" will merge those settings. I think the reason the tests will fail is because the config is cached once invoked. It seems intentional though. |
Hiya,
Really new to this project and dry-rb in general, so I don't expect to hit the mark on my first try, but this PR fixes #109
I'm curious if this is the desired api, or if it would be easier to copy settings from another Dry::Configurable class or object without accessing what I am assuming to be a an internal var?
I was thinking..