Skip to content

Commit 1c3a180

Browse files
committed
disable root as flag option
1 parent c8fcb60 commit 1c3a180

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

lib/active_model/serializer.rb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,6 @@ def self.adapter
145145
adapter_class
146146
end
147147

148-
def self._root
149-
@@root ||= false
150-
end
151-
152-
def self._root=(root)
153-
@@root = root
154-
end
155-
156148
def self.root_name
157149
name.demodulize.underscore.sub(/_serializer$/, '') if name
158150
end
@@ -162,7 +154,7 @@ def self.root_name
162154
def initialize(object, options = {})
163155
@object = object
164156
@options = options
165-
@root = options[:root] || (self.class._root ? self.class.root_name : false)
157+
@root = options[:root]
166158
@meta = options[:meta]
167159
@meta_key = options[:meta_key]
168160
@scope = options[:scope]
@@ -176,7 +168,7 @@ def initialize(object, options = {})
176168
end
177169

178170
def json_key
179-
if root == true || root.nil?
171+
if root.nil?
180172
self.class.root_name
181173
else
182174
root

lib/active_model/serializer/adapter/flatten_json.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ def serializable_hash(options = {})
88
super
99
@result
1010
end
11-
end
1211

13-
def fragment_cache(cached_hash, non_cached_hash)
14-
Json::FragmentCache.new().fragment_cache(cached_hash, non_cached_hash)
12+
def root
13+
false
14+
end
1515
end
1616
end
1717
end

0 commit comments

Comments
 (0)