Fix Resource#to_h returning nil instead of matching #to_hash - #319
Merged
Conversation
Danger ReportNo issues found. |
dblock
force-pushed
the
dblock/fix-resource-to-h
branch
from
August 26, 2026 21:38
66bff17 to
6692df4
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dblock
force-pushed
the
dblock/fix-resource-to-h
branch
from
August 26, 2026 21:48
6692df4 to
f47b4fe
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #103.
Root cause
Resource#to_h/#to_hashare not explicitly defined; they were both routed throughmethod_missing, which delegates to_attributes(aCollection, which does define both#to_hand#to_hash) — but only if the method isn't already defined onArray:Arraydefines#to_hbut not#to_hash:So
#to_hashcorrectly falls through the guard and delegates to_attributes.to_hash, but#to_hgets blocked by the guard, andmethod_missing'selsifbranch simply does nothing in that case — returningnilinstead of raising or delegating.Fix
Explicitly define
#to_honResource, delegating to_attributes.to_h, and alias#to_hashto it — removing the need to rely on theArray.method_defined?heuristic for this specific pair of methods.Checklist