Merge pull request #6938 from acapilleri/as_json_refactoring
Small refactoring of as_json method
This commit is contained in:
commit
d4f59783d2
@ -87,8 +87,12 @@ module JSON
|
||||
# # { "comments" => [ { "body" => "Don't think too hard" } ],
|
||||
# # "title" => "So I was thinking" } ] }
|
||||
def as_json(options = nil)
|
||||
root = include_root_in_json
|
||||
root = options[:root] if options.try(:key?, :root)
|
||||
root = if options && options.key?(:root)
|
||||
options[:root]
|
||||
else
|
||||
include_root_in_json
|
||||
end
|
||||
|
||||
if root
|
||||
root = self.class.model_name.element if root == true
|
||||
{ root => serializable_hash(options) }
|
||||
|
Loading…
Reference in New Issue
Block a user