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

Fixes behavior of [] method for optional key #177

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ivleonov
Copy link

It fixes #171

Few notes about this fix:

  • The assumption here is that @attributes are already validated, so no need to go to schema and check if given key is actually optional
  • Another idea here is to merge missing optional keys in @attributes variable at the moment of creating object to make sure that behavior is consistent across access methods, hash syntax ([]) and methods attributes, to_h and to_hash. Currently attributes, to_h and to_hash methods don't not return missing keys. But I'm not sure if it's reasonable behavior change (maybe someone relies on current behavior). Pls let me know if you feel so and I will extend this PR (or will open another one)

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.

MissingAttributeError when access optional field with hash syntax
1 participant