Move use of serializers cache out of Utils

This commit is contained in:
Dylan Thacker-Smith 2017-03-15 17:33:04 -04:00
parent d02ee692aa
commit d58a6e13b0
3 changed files with 15 additions and 10 deletions

View File

@ -33,7 +33,11 @@ module ActiveModel
end end
def namespace def namespace
get_namespace && Utils._const_get(get_namespace) if module_name = get_namespace
Serializer.serializers_cache.fetch_or_store(module_name) do
Utils._const_get(module_name)
end
end
end end
def embedded_in_root_associations def embedded_in_root_associations

View File

@ -4,7 +4,6 @@ module ActiveModel
extend self extend self
def _const_get(const) def _const_get(const)
Serializer.serializers_cache.fetch_or_store(const) do
begin begin
method = RUBY_VERSION >= '2.0' ? :const_get : :qualified_const_get method = RUBY_VERSION >= '2.0' ? :const_get : :qualified_const_get
Object.send method, const Object.send method, const
@ -15,4 +14,3 @@ module ActiveModel
end end
end end
end end
end

View File

@ -66,7 +66,10 @@ end
ArraySerializer ArraySerializer
end end
else else
_const_get build_serializer_class(resource, options) klass_name = build_serializer_class(resource, options)
Serializer.serializers_cache.fetch_or_store(klass_name) do
_const_get(klass_name)
end
end end
end end