Skip to content

Conversation

@Syati
Copy link
Owner

@Syati Syati commented Sep 9, 2025

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 boolean compact option with a new compact_mode keyword 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

  • The attributes and serialize_structured_value methods in lib/structured_params/params.rb now accept a compact_mode keyword argument (:none, :nil_only, or :all_blank) instead of a simple boolean compact. This allows more granular control over how blank or nil values are removed from serialized output. [1] [2]
  • The Sorbet type signatures in sig/structured_params/params.rbs have been updated to reflect the new compact_mode argument and its possible values. [1] [2]

Test coverage for new compaction modes

  • The specs in spec/params_spec.rb have been updated to use compact_mode instead of compact, and new tests have been added for the :all_blank mode to verify recursive removal of blank values from nested structures. [1] [2] [3] [4]

Miscellaneous updates

  • The RuboCop configuration now enforces a maximum method length of 20 lines for better code quality. (.rubocop.yml)
  • The CHANGELOG.md file has been cleaned up by removing outdated entries for unreleased versions.…lace compact boolean with compact_mode keyword argument, including updated specs, method signatures, and tests.

…lace `compact` boolean with `compact_mode` keyword argument, including updated specs, method signatures, and tests.
Copilot AI review requested due to automatic review settings September 9, 2025 01:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 compact parameter with compact_mode keyword supporting multiple compaction strategies
  • Updates method signatures and type annotations to reflect the new API
  • Adds comprehensive test coverage for the new :all_blank compaction 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.

Syati and others added 2 commits September 9, 2025 10:41
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Syati Syati merged commit 939f4e1 into main Sep 9, 2025
6 checks passed
@Syati Syati deleted the add-compact_mode branch September 9, 2025 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants