Merge pull request #6938 from acapilleri/as_json_refactoring

Small refactoring of as_json method
This commit is contained in:
Carlos Antonio da Silva 2012-07-07 06:39:56 -07:00
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) }