mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16: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
|
||||
end
|
||||
|
||||
def self._root
|
||||
@@root ||= false
|
||||
end
|
||||
|
||||
def self._root=(root)
|
||||
@@root = root
|
||||
end
|
||||
|
||||
def self.root_name
|
||||
name.demodulize.underscore.sub(/_serializer$/, '') if name
|
||||
end
|
||||
@ -162,7 +154,7 @@ module ActiveModel
|
||||
def initialize(object, options = {})
|
||||
@object = object
|
||||
@options = options
|
||||
@root = options[:root] || (self.class._root ? self.class.root_name : false)
|
||||
@root = options[:root]
|
||||
@meta = options[:meta]
|
||||
@meta_key = options[:meta_key]
|
||||
@scope = options[:scope]
|
||||
@ -176,7 +168,7 @@ module ActiveModel
|
||||
end
|
||||
|
||||
def json_key
|
||||
if root == true || root.nil?
|
||||
if root.nil?
|
||||
self.class.root_name
|
||||
else
|
||||
root
|
||||
|
||||
@ -8,10 +8,10 @@ module ActiveModel
|
||||
super
|
||||
@result
|
||||
end
|
||||
end
|
||||
|
||||
def fragment_cache(cached_hash, non_cached_hash)
|
||||
Json::FragmentCache.new().fragment_cache(cached_hash, non_cached_hash)
|
||||
def root
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user