instance method
quote
Ruby on Rails 6.0.6
Since v4.2.9 PrivateSignature
quote(value)
Surround string with single quotes if there is no quotes. Otherwise fall back to double quotes
Parameters
-
valuereq
Source
# File railties/lib/rails/generators/actions.rb, line 309
def quote(value) # :doc:
if value.respond_to? :each_pair
return value.map do |k, v|
"#{k}: #{quote(v)}"
end.join(", ")
end
return value.inspect unless value.is_a? String
if value.include?("'")
value.inspect
else
"'#{value}'"
end
end
Defined in railties/lib/rails/generators/actions.rb line 309
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Rails::Generators::Actions