aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorGodfrey Chan <godfreykfc@gmail.com>2013-11-22 11:01:40 -0800
committerGodfrey Chan <godfreykfc@gmail.com>2013-11-22 11:01:40 -0800
commit663c059d4a043e0baabb69e60436bb849eb620fb (patch)
tree9b91d30c4880500da68a613a6ff4ed8474928897 /activesupport/lib
parent34c08d2ead9360e1d9577dbc491d221ab66a2151 (diff)
downloadrails-663c059d4a043e0baabb69e60436bb849eb620fb.tar.gz
rails-663c059d4a043e0baabb69e60436bb849eb620fb.tar.bz2
rails-663c059d4a043e0baabb69e60436bb849eb620fb.zip
When Array#as_json and Hash#as_json are called without options, they
should also call #as_json on the children without options (instead of nil)
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/object/json.rb4
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: