Uh oh!
There was an error while loading. Please reload this page.
Add has_key? method to OpenStruct class - #74
Conversation
marcandre
commented
Feb 19, 2025
What is the usecase? |
ingemar
commented
May 30, 2025
@djberube I would argue that this method should be named |
o-200
commented
Sep 21, 2025
Hey, for me it's will helpful when i need to validate the structure and serialize JSON and API'S. I am really interested of that and i want to finish implementing the feature of seeking keys in OpenStruct. Can i just create my own fork and give Co-Authoring to @djberube when it will be done? |
Adds has_key? method to OpenStruct class to check if a given name exists as a member. This allows checking for presence of a key without creating an accessor method. Method accepts both string and symbol keys, converting them to symbols before checking. Includes comprehensive test coverage for various usage scenarios.
4758a89 to
4e6c286Compare
Makes sense; we should follow what Hash does. Adjusted as requested. @o-200 I have made the requested changes, but feel free to suggest any changes that would help your use case. |
o-200
commented
Sep 21, 2025
Thanks! Appreciate that you returned after six months to finish that pull request. |
ingemar
commented
Sep 22, 2025
@djberube This is excellent. Thank you! |
Adds has_key? method to OpenStruct class to check if a given name exists as a member, which allows checking for presence of a key without creating an accessor method; it also allows for distinguishing between a method which has never been set and one which been set to nil.