Refactor attributes and serialize_structured_value methods to rep…#9
Merged
Refactor attributes and serialize_structured_value methods to rep…#9
attributes and serialize_structured_value methods to rep…#9Conversation
…lace `compact` boolean with `compact_mode` keyword argument, including updated specs, method signatures, and tests.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request refactors the attributes and serialize_structured_value methods in StructuredParams::Params by replacing the boolean compact parameter with a more flexible compact_mode keyword argument that supports three modes: :none, :nil_only, and :all_blank.
- Replaces boolean
compactparameter withcompact_modekeyword supporting multiple compaction strategies - Updates method signatures and type annotations to reflect the new API
- Adds comprehensive test coverage for the new
:all_blankcompaction mode
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lib/structured_params/params.rb | Updates attributes and serialize_structured_value methods to use compact_mode instead of compact |
| sig/structured_params/params.rbs | Updates type signatures to reflect new compact_mode parameter and its possible values |
| spec/params_spec.rb | Updates existing tests to use compact_mode and adds new test cases for :all_blank mode |
| CHANGELOG.md | Removes outdated unreleased version entries |
| .rubocop.yml | Adds maximum method length configuration |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
This pull request enhances the handling of attribute serialization and compaction in
StructuredParams::Params, making the API more flexible and expressive. The main change is replacing the previous booleancompactoption with a newcompact_modekeyword argument, which supports multiple modes for removing blank or nil values. The update also modifies related method signatures, updates type signatures, and adds comprehensive tests for the new behavior.Attribute serialization and compaction improvements
attributesandserialize_structured_valuemethods inlib/structured_params/params.rbnow accept acompact_modekeyword argument (:none,:nil_only, or:all_blank) instead of a simple booleancompact. This allows more granular control over how blank or nil values are removed from serialized output. [1] [2]sig/structured_params/params.rbshave been updated to reflect the newcompact_modeargument and its possible values. [1] [2]Test coverage for new compaction modes
spec/params_spec.rbhave been updated to usecompact_modeinstead ofcompact, and new tests have been added for the:all_blankmode to verify recursive removal of blank values from nested structures. [1] [2] [3] [4]Miscellaneous updates
.rubocop.yml)CHANGELOG.mdfile has been cleaned up by removing outdated entries for unreleased versions.…lacecompactboolean withcompact_modekeyword argument, including updated specs, method signatures, and tests.