Conversation
Applies a selector as an exclusion: matched fields are removed and every other field passes through unchanged. Uses the same grammar, parser limits, and traversal rules as selection. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Author
|
Closing: this adds exclusion masking, which goes beyond the nemtsov/json-mask reference implementation this gem mirrors (inclusion-only |
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.
Summary
Adds an exclusion counterpart to the existing selection API:
JsonMask.except(value, fields)andJsonMask.compile_except(fields)remove the fields a selector matches and pass every other field through unchanged.Exclusion masks reuse the existing parser, grammar, and limits — the selector language is unchanged and stays Google partial-response compliant. The new
ExclusionProjectormirrorsProjectorwith inverted semantics:permissions(email)keepspermissions, removes each entry'semail).nilunder a nested exclusion are kept as-is (nothing deeper to remove).nil/blank selectors remove nothing and return the value unchanged.CompiledMaskgains an internalprojector:collaborator so both mask kinds share the compile/reuse/fields-accessor behavior.ExclusionProjectoris a private constant, matchingProjector.Motivation
Wistia's MCP server wants Drive-style default representations: sensitive fields (e.g. registrant emails on analytics tools) omitted from responses unless a caller explicitly selects them. Building that default requires "everything except these paths" projection, which the inclusion-only grammar can't express — this API provides it server-side without extending the wire syntax.
Testing
bundle exec rake(tests + RuboCop): 44 runs, 105 assertions, 0 failures; 14 files inspected, no offenses.Version bumped to 0.2.0 with a CHANGELOG entry; README documents the new API.
🤖 Generated with Claude Code