Skip to content

Any plans to support only and except? #34

Answered by ElMassimo
frysch asked this question in Q&A
Discussion options

You must be logged in to vote

Hi Anders!

One of the reasons this library is more performant is that the code for serialization is generated at load time.

Supporting only and except would require dynamically iterating the list of attributes to find out which ones to render, which is slower.

I'd be open to supporting it if we find an implementation that does not negatively affect the default case. That might require using a different execution path when only or except are provided.


As a workaround when migrating from AMS or similar libraries, you can use the if option in an attribute, for example:

attribute :name, if: -> { !options[:except]&.include?(:name) }

For performance (and for robustness if generating types fro…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by frysch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants