Expose allowed attribute keys #48
Closed
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.
So that cleanup methods can rely on a list of allowed keys and do not have to maintain their copy that can get out of date.
Specifically, I noticed that the following snippet does not support the new keys added in #43, #46 and
unit:https://github.com/easolhq/easol/blob/4fb589fc4f59f1f7f633a13098bc038f34c62bb4/app/models/site/variable_config/normalize_all_schemas.rb#L9-L22
Given the validators here were added after
NormalizeAllSchemas, it sounded reasonable to delegate the list of fields to this gem.Implementation note
SchemaAttribute::Base#permitted_keysdoes not have to be an instance method, but refactoring to a class method would have involved movingrequired_keysandoptional_keystoo, which I felt was more significant than necessary here. Happy to change my mind, though 😄An alternative approach could be to inline the cleaning and normalising of one schema into this gem from
NormalizeAllSchemas. Happy to explore that too.