mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
improved caching of root node for better performance
This commit is contained in:
parent
324f9d83b3
commit
af13d48dfa
@ -17,6 +17,14 @@ module ActiveModel
|
||||
end
|
||||
|
||||
self.options = class_options
|
||||
|
||||
# cache the root so we can reuse it without falling back on a per-instance basis
|
||||
begin
|
||||
self.options[:root] ||= self.new(name, nil).root
|
||||
rescue
|
||||
# this could fail if it needs a valid source, for example a polymorphic association
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user