Use ActiveModel's normalize to strip records
#84
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.
Hi and thanks for maintaining this gem!
Here's a potential implementation of
normalizeto strip records (#67).There are two caveats:
ActiveModelnow has to be used instead ofActiveAttrto build test objects. Also plainActiveAttrmodels lack.normalizemethod, thus aren't supported anymore.ifandunlessoptions are no longer supported.normalizedoesn't have those options and the record isn't available in thenormalizecontext. I guess this kinda makes sense, because without this option, we're normalizing the data consistently across all instances of a specific model. However it sucks that the gem's API is changedIf
normalizeapproach is something we want to continue with, there are few things left for me to do:#save(validate: false)works, etc.)ifandunlessfromVALID_OPTIONS, and delete tests forifandunlessoptionsFeel free to question, criticize and comment 🙏