From 71437f620f6c7f2a86c4fe07a10c41279fbbc886 Mon Sep 17 00:00:00 2001 From: Ashik Salman Date: Tue, 4 May 2021 16:43:34 +0530 Subject: [PATCH] Updated #quote comments and removed if-else block. --- railties/lib/rails/generators/actions.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index bbf5b10d44616..5006cb9712524 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -323,8 +323,7 @@ def extify(name) # :doc: end end - # Surround string with single quotes if there is no quotes. - # Otherwise fall back to double quotes + # Always returns value in double quotes. def quote(value) # :doc: if value.respond_to? :each_pair return value.map do |k, v| @@ -333,11 +332,7 @@ def quote(value) # :doc: end return value.inspect unless value.is_a? String - if value.include?("'") - value.tr("'", '"') - else - "\"#{value}\"" - end + "\"#{value.tr("'", '"')}\"" end # Returns optimized string with indentation