Fix DeepHashAccessor#[] and generate typed nested resource classes - #539
Open
razor-x wants to merge 1 commit into
Open
Fix DeepHashAccessor#[] and generate typed nested resource classes#539razor-x wants to merge 1 commit into
razor-x wants to merge 1 commit into
Conversation
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.
Motivation
DeepHashAccessor#[]always returnedniland produced non-stable nested objects, and prevent response deserialization from aborting on invalid Ruby ivar names.errors/warningsare refreshed afterupdate_from_responseto avoid stale data.BaseResourcesubclasses for nested objects and lists.Description
DeepHashAccessor:#[]now delegates to the generated singleton readers (accepting string or symbol keys) andcreate_accessor_methodsnow processes values once at construction to preserve identity. (lib/seam/deep_hash_accessor.rb).BaseResourcedeserialization to returnnilfromload_from_response(nil), skip response keys that cannot be valid instance variable names, addedBaseResource#[]for bracket access, and introducedresource_accessor/resource_list_accessorDSL and conversion logic to instantiate typed nested resources when present. (lib/seam/base_resource.rb).@errors_convertedand@warnings_convertedbefore delegatingupdate_from_responsein the resource support modules, and updated the emitted string literals used by the generator (codegen/lib/static-resources.ts→lib/seam/resources/resource_errors_support.rbandresource_warnings_support.rb).merge-propertieshelper and updatedcodegen/lib/layouts/resource.tsandcodegen/layouts/resource.hbsso generatedlib/seam/resources/*.rbnow emit documented nestedBaseResourcesubclasses and declareresource_accessor/resource_list_accessorusages; numerous generated resource files were refreshed accordingly.spec/deep_hash_accessor_spec.rb,spec/resources/base_resource_hash_spec.rb, andspec/resources/base_resource_spec.rbnow assert bracket access, stable nested identity, nil handling forload_from_response(nil), skipping invalid attribute names,errorsrefresh on update, and that declared nested objects become generated typed resources.Testing
bundle exec rspecfor the modified suites and they passed (includingspec/deep_hash_accessor_spec.rb,spec/resources/base_resource_spec.rb, andspec/resources/base_resource_hash_spec.rb).npm run generate(generator run and idempotency check),rake lint, andrake testcompleted successfully after minor tooling fixes in the generator templates.npm run typecheckand JavaScript lint/format (npm run lint/prettier) during generator development and fixed reported issues; note that the local Node runtime triggered an engine warning because it is older than the project dev engine requirement (this did not prevent generation in this environment).resource_accessordeclarations as expected.Codex Task