Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix usage of #to_h and #to_hash across our object models #7699
Most objects that aren't really hash like shouldn't implement #to_hash at all.
Objects like DataBagItem which really are a wrapper around a Hash (which does delegate all its methods to Hash) should implement #to_hash but should return the actual inner @raw_data hash. Returning the serialized version of the data bag with the json_class, etc is incorrect. I think we should likely implement a #for_json that returns the serialized hash version which #to_json should call consistently. Then many not-actually-hash-like objects would drop #to_hash entirely, they would have a #to_h which was aliased to #for_json. Other actually-hash-like objects would have #to_hash and #to_h that would be aliased together, while #for_json was the serialized version.