Skip to content

Commit

Permalink
Updated #quote comments and removed if-else block.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashiksp committed May 4, 2021
1 parent daaa3b5 commit 71437f6
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions railties/lib/rails/generators/actions.rb
Expand Up @@ -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|
Expand All @@ -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
Expand Down

0 comments on commit 71437f6

Please sign in to comment.