diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2012-10-05 11:52:20 -0300 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2012-10-05 11:52:20 -0300 |
commit | abf8de85519141496a6773310964ec03f6106f3f (patch) | |
tree | 5149d0c61125567f0e704d2f520611a1718e168a /guides | |
parent | 5c078368c762ec025997af6b2c94632b2f9301d2 (diff) | |
download | rails-abf8de85519141496a6773310964ec03f6106f3f.tar.gz rails-abf8de85519141496a6773310964ec03f6106f3f.tar.bz2 rails-abf8de85519141496a6773310964ec03f6106f3f.zip |
Use flat_map { } instead of map {}.flatten
Diffstat (limited to 'guides')
-rw-r--r-- | guides/rails_guides/helpers.rb | 2 | ||||
-rw-r--r-- | guides/source/active_support_core_extensions.md | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/guides/rails_guides/helpers.rb b/guides/rails_guides/helpers.rb index e6ef656474..c8ab9e4536 100644 --- a/guides/rails_guides/helpers.rb +++ b/guides/rails_guides/helpers.rb @@ -17,7 +17,7 @@ module RailsGuides end def documents_flat - documents_by_section.map {|section| section['documents']}.flatten + documents_by_section.flat_map {|section| section['documents']} end def finished_documents(documents) diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md index 2a84242b9c..1930cbe22c 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.map {|k, v| [k, v.to_s]}.flatten] + params = Hash[*params.flat_map {|k, v| [k, v.to_s]}] 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.map {|k, v| [k, v.to_s]}.flatten] + params = Hash[*params.flat_map {|k, v| [k, v.to_s]}] 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.map {|k, v| [k, v.to_s]}.flatten] + params = Hash[*params.flat_map {|k, v| [k, v.to_s]}] process_without_stringified_params(action, params, session, flash, http_method) end alias_method_chain :process, :stringified_params |