Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.9 stable] Lazily compute possible serializer class names #2467

Merged

Conversation

casperisfine
Copy link

There is no point computing them all and then later look them up.

cc @bf4

There is no point computing them all and then later
look them up.
@byroot byroot merged commit 14f465c into rails-api:0-9-stable Apr 10, 2024
7 checks passed
@casperisfine casperisfine deleted the 0-9-stable-lazy-serializer-list branch April 10, 2024 07:41
serializer = Serializer.serializers_cache.fetch_or_store(klass_name) do
_const_get(klass_name)
end
return serializer unless serializer.nil?
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I try to avoid return in a block. Break would work, too, no?

Copy link
Author

Choose a reason for hiding this comment

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

Break could work yes. I find return from a block quite idomatic, but feel free to change the style if you feel strongly about it.

The goal here was first and foremost to reduce the overhead.

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.

None yet

3 participants