File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed
activemodel/lib/active_model/serializers Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -86,16 +86,12 @@ module JSON
86
86
# "title": "Welcome to the weblog"},
87
87
# {"comments": [{"body": "Don't think too hard"}],
88
88
# "title": "So I was thinking"}]}
89
-
90
89
def as_json ( options = nil )
91
- opts_root = options [ :root ] if options . try ( :key? , :root )
92
- if opts_root
93
- custom_root = opts_root == true ? self . class . model_name . element : opts_root
94
- { custom_root => serializable_hash ( options ) }
95
- elsif opts_root == false
96
- serializable_hash ( options )
97
- elsif include_root_in_json
98
- { self . class . model_name . element => serializable_hash ( options ) }
90
+ root = include_root_in_json
91
+ root = options [ :root ] if options . try ( :key? , :root )
92
+ if root
93
+ root = self . class . model_name . element if root == true
94
+ { root => serializable_hash ( options ) }
99
95
else
100
96
serializable_hash ( options )
101
97
end
You can’t perform that action at this time.
0 commit comments