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
|
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
|
||||||
|
|||||||
@ -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
|
|
||||||
|
|||||||
@ -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
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user