Add has_key? method to OpenStruct class
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.
What is the usecase?
@djberube I would argue that this method should be named #include? as in Hash#include?, and subsequently aliased as #has_key? and #key?. What do you think?
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?
@djberube I would argue that this method should be named
#include?as in Hash#include?, and subsequently aliased as#has_key?and#key?. What do you think?
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 I have made the requested changes,
Thanks! Appreciate that you returned after six months to finish that pull request.
@djberube This is excellent. Thank you!