mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 23:06:50 +00:00
disable root as flag option
This commit is contained in:
parent
c8fcb60a5d
commit
1c3a180a20
@ -145,14 +145,6 @@ module ActiveModel
|
|||||||
adapter_class
|
adapter_class
|
||||||
end
|
end
|
||||||
|
|
||||||
def self._root
|
|
||||||
@@root ||= false
|
|
||||||
end
|
|
||||||
|
|
||||||
def self._root=(root)
|
|
||||||
@@root = root
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.root_name
|
def self.root_name
|
||||||
name.demodulize.underscore.sub(/_serializer$/, '') if name
|
name.demodulize.underscore.sub(/_serializer$/, '') if name
|
||||||
end
|
end
|
||||||
@ -162,7 +154,7 @@ module ActiveModel
|
|||||||
def initialize(object, options = {})
|
def initialize(object, options = {})
|
||||||
@object = object
|
@object = object
|
||||||
@options = options
|
@options = options
|
||||||
@root = options[:root] || (self.class._root ? self.class.root_name : false)
|
@root = options[:root]
|
||||||
@meta = options[:meta]
|
@meta = options[:meta]
|
||||||
@meta_key = options[:meta_key]
|
@meta_key = options[:meta_key]
|
||||||
@scope = options[:scope]
|
@scope = options[:scope]
|
||||||
@ -176,7 +168,7 @@ module ActiveModel
|
|||||||
end
|
end
|
||||||
|
|
||||||
def json_key
|
def json_key
|
||||||
if root == true || root.nil?
|
if root.nil?
|
||||||
self.class.root_name
|
self.class.root_name
|
||||||
else
|
else
|
||||||
root
|
root
|
||||||
|
|||||||
@ -8,10 +8,10 @@ module ActiveModel
|
|||||||
super
|
super
|
||||||
@result
|
@result
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def fragment_cache(cached_hash, non_cached_hash)
|
def root
|
||||||
Json::FragmentCache.new().fragment_cache(cached_hash, non_cached_hash)
|
false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user