dry-struct
dry-struct copied to clipboard
Fixes behavior of `[]` method for optional key
It fixes #171
Few notes about this fix:
- The assumption here is that
@attributesare 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
@attributesvariable at the moment of creating object to make sure that behavior is consistent across access methods, hash syntax ([]) and methodsattributes,to_handto_hash. Currentlyattributes,to_handto_hashmethods 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)