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
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
def embedded_in_root_associations

View File

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

View File

@ -66,7 +66,10 @@ end
ArraySerializer
end
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