-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
Does the check for unknown positional parameters work? #68
Comments
You are right, the gem does not check the number of params, but just ignores the unknown ones. This was made by design, because at the moment I got no good solution for adding stars (I mean both * and **) into the DSL. Now the migration to stricter checks is possible in theory, but this decision would cause a huge backward-incompatibility, so I would prefer not to make the change. |
I see... I was just asking since it seems to contradict an intuitive reading of the documentation ( https://dry-rb.org/gems/dry-initializer/options-tolerance/ ). So it would maybe be good to add a section about this behaviour.... About the strict parameters.. How about parametrizing the module (builder) and adding parameters strict checking parameters for this? include Dry::Initializer.define(allow_unknown_params: false) -> do
...
end Though I'm not sure what would be an backcompatible way for the normal extend version. Maybe a something like. extend Dry::Initializer.with_options(allow_unknown_params: false) |
just bumped in this myself as well. Should the documentation be updated to correctly reflect the fact that positional arguments are not strict? Right now it says the following:
which doesn't seem to be case. As the current real behaviour is different from Ruby's own behaviour, I think it's worth documenting this correctly. |
Fix documentation for unknown arguments (#68)
Does the much stricter Ruby behavior around handling args and keyword args make it simpler for us to enforce the same in the gem? |
Hi,
thank you for this useful gem! I have one question about the design choice of how to generate the constructor of the object.
dry-initializer/lib/dry/initializer/builders/signature.rb
Lines 8 to 10 in 3167b5a
Why is the '*' included in the parameter list? Wouldn't that just match all positional arguments regardless of whether they are defined or not?
The text was updated successfully, but these errors were encountered: