improved caching of root node for better performance

This commit is contained in:
Sam 2013-03-18 16:21:34 -07:00
parent 324f9d83b3
commit af13d48dfa

View File

@ -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