diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2013-11-22 16:01:22 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2013-11-22 16:01:22 -0800 |
commit | 5542dff88a8581675c9324c8184cc80df99e3325 (patch) | |
tree | a4092093382343b02c1f4eb7f3ab8f2932cb9cd6 /activesupport/lib/active_support/core_ext | |
parent | 818b362c1db0b1103d6489dbd6f1f56e645a34e3 (diff) | |
parent | 663c059d4a043e0baabb69e60436bb849eb620fb (diff) | |
download | rails-5542dff88a8581675c9324c8184cc80df99e3325.tar.gz rails-5542dff88a8581675c9324c8184cc80df99e3325.tar.bz2 rails-5542dff88a8581675c9324c8184cc80df99e3325.zip |
Merge pull request #13007 from chancancode/dont_call_as_json_with_nil
Don't call #as_json on children of Array and Hash with nil when no arguments are passed
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r-- | activesupport/lib/active_support/core_ext/object/json.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/json.rb b/activesupport/lib/active_support/core_ext/object/json.rb index 5157b0402f..1a1fa1eedd 100644 --- a/activesupport/lib/active_support/core_ext/object/json.rb +++ b/activesupport/lib/active_support/core_ext/object/json.rb @@ -164,7 +164,7 @@ end class Array def as_json(options = nil) #:nodoc: - map { |v| v.as_json(options && options.dup) } + map { |v| options ? v.as_json(options.dup) : v.as_json } end def encode_json(encoder) #:nodoc: @@ -187,7 +187,7 @@ class Hash self end - Hash[subset.map { |k, v| [k.to_s, v.as_json(options && options.dup)] }] + Hash[subset.map { |k, v| [k.to_s, options ? v.as_json(options.dup) : v.as_json] }] end def encode_json(encoder) #:nodoc: |