Skip to content

Commit ca1baa0

Browse files
committed
Cache custom_generation_options options
This hash only needs to be computed once, and repeatedly building it results in a lot of memory allocations.
1 parent 3b8cc74 commit ca1baa0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/jsonapi/resource_serializer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def attributes_hash(source, fetchable_fields)
230230
end
231231

232232
def custom_generation_options
233-
{
233+
@_custom_generation_options ||= {
234234
serializer: self,
235235
serialization_options: @serialization_options
236236
}

0 commit comments

Comments
 (0)