mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 23:06:50 +00:00
Merge pull request #242 from SamSaffron/fix
this little bit of caching gives us a massive perf gain on Discourse
This commit is contained in:
commit
5d2ae9b138
@ -17,6 +17,14 @@ module ActiveModel
|
|||||||
end
|
end
|
||||||
|
|
||||||
self.options = class_options
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user