diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2012-10-05 12:07:16 -0300 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2012-10-05 12:07:16 -0300 |
commit | a0613ad8a9773c76a9b0a256f7099fde35823674 (patch) | |
tree | ac866e7a5c8fa4c15f025759dd0ed1dccb54d311 /guides/source | |
parent | abf8de85519141496a6773310964ec03f6106f3f (diff) | |
download | rails-a0613ad8a9773c76a9b0a256f7099fde35823674.tar.gz rails-a0613ad8a9773c76a9b0a256f7099fde35823674.tar.bz2 rails-a0613ad8a9773c76a9b0a256f7099fde35823674.zip |
Revert "Use flat_map { } instead of map {}.flatten"
This reverts commit abf8de85519141496a6773310964ec03f6106f3f.
We should take a deeper look to those cases flat_map doesn't do deep
flattening.
irb(main):002:0> [[[1,3], [1,2]]].map{|i| i}.flatten
=> [1, 3, 1, 2]
irb(main):003:0> [[[1,3], [1,2]]].flat_map{|i| i}
=> [[1, 3], [1, 2]]
Diffstat (limited to 'guides/source')
-rw-r--r-- | guides/source/active_support_core_extensions.md | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md index 1930cbe22c..2a84242b9c 100644 --- a/guides/source/active_support_core_extensions.md +++ b/guides/source/active_support_core_extensions.md @@ -517,7 +517,7 @@ ActionController::TestCase.class_eval do # now redefine process and delegate to original_process def process(action, params=nil, session=nil, flash=nil, http_method='GET') - params = Hash[*params.flat_map {|k, v| [k, v.to_s]}] + params = Hash[*params.map {|k, v| [k, v.to_s]}.flatten] original_process(action, params, session, flash, http_method) end end @@ -530,7 +530,7 @@ That technique has a risk, it could be the case that `:original_process` was tak ```ruby ActionController::TestCase.class_eval do def process_with_stringified_params(...) - params = Hash[*params.flat_map {|k, v| [k, v.to_s]}] + params = Hash[*params.map {|k, v| [k, v.to_s]}.flatten] process_without_stringified_params(action, params, session, flash, http_method) end alias_method :process_without_stringified_params, :process @@ -543,7 +543,7 @@ The method `alias_method_chain` provides a shortcut for that pattern: ```ruby ActionController::TestCase.class_eval do def process_with_stringified_params(...) - params = Hash[*params.flat_map {|k, v| [k, v.to_s]}] + params = Hash[*params.map {|k, v| [k, v.to_s]}.flatten] process_without_stringified_params(action, params, session, flash, http_method) end alias_method_chain :process, :stringified_params |