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
8686 # "title": "Welcome to the weblog"},
8787 # {"comments": [{"body": "Don't think too hard"}],
8888 # "title": "So I was thinking"}]}
89-
9089 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 ) }
9995 else
10096 serializable_hash ( options )
10197 end
You can’t perform that action at this time.
0 commit comments