mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Move use of serializers cache out of Utils
This commit is contained in:
parent
d02ee692aa
commit
d58a6e13b0
@ -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
|
||||
|
||||
@ -4,13 +4,11 @@ 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
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user