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
@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 methodsattributes
,to_h
andto_hash
. Currentlyattributes
,to_h
andto_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)