Skip to content

Commit

Permalink
Remove redundant to_s in interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiob committed Oct 30, 2014
1 parent 7cf4d54 commit 64b0982
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/routing/inspector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def json_regexp
def reqs
@reqs ||= begin
reqs = endpoint
reqs += " #{constraints.to_s}" unless constraints.empty?
reqs += " #{constraints}" unless constraints.empty?
reqs
end
end
Expand Down
4 changes: 2 additions & 2 deletions actionpack/test/controller/mime/respond_to_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -579,10 +579,10 @@ def render(*args)
end

get :using_defaults
assert_equal "using_defaults - #{[:html].to_s}", @response.body
assert_equal "using_defaults - #{[:html]}", @response.body

get :using_defaults, :format => "xml"
assert_equal "using_defaults - #{[:xml].to_s}", @response.body
assert_equal "using_defaults - #{[:xml]}", @response.body
end

def test_format_with_custom_response_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def _quote(value)
when Numeric, ActiveSupport::Duration then value.to_s
when Date, Time then "'#{quoted_date(value)}'"
when Symbol then "'#{quote_string(value.to_s)}'"
when Class then "'#{value.to_s}'"
when Class then "'#{value}'"
else
"'#{quote_string(YAML.dump(value))}'"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module ConnectionAdapters # :nodoc:
module ColumnDumper
def column_spec(column, types)
spec = prepare_column_options(column, types)
(spec.keys - [:name, :type]).each{ |k| spec[k].insert(0, "#{k.to_s}: ")}
(spec.keys - [:name, :type]).each{ |k| spec[k].insert(0, "#{k}: ")}
spec
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ def type_cast_for_schema(value)

# If the subnet mask is equal to /32, don't output it
if subnet_mask == (2**32 - 1)
"\"#{value.to_s}\""
"\"#{value}\""
else
"\"#{value.to_s}/#{subnet_mask.to_s(2).count('1')}\""
"\"#{value}/#{subnet_mask.to_s(2).count('1')}\""
end
end

def type_cast_for_database(value)
if IPAddr === value
"#{value.to_s}/#{value.instance_variable_get(:@mask_addr).to_s(2).count('1')}"
"#{value}/#{value.instance_variable_get(:@mask_addr).to_s(2).count('1')}"
else
value
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def quote(value, column = nil) #:nodoc:
case value
when Float
if value.infinite? || value.nan?
"'#{value.to_s}'"
"'#{value}'"
else
super
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,9 +679,9 @@ def configure_connection
variables.map do |k, v|
if v == ':default' || v == :default
# Sets the value to the global or compile default
execute("SET SESSION #{k.to_s} TO DEFAULT", 'SCHEMA')
execute("SET SESSION #{k} TO DEFAULT", 'SCHEMA')
elsif !v.nil?
execute("SET SESSION #{k.to_s} TO #{quote(v)}", 'SCHEMA')
execute("SET SESSION #{k} TO #{quote(v)}", 'SCHEMA')
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions activerecord/test/cases/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,23 @@ def with_timezone_config(cfg)
def verify_default_timezone_config
if Time.zone != EXPECTED_ZONE
$stderr.puts <<-MSG
\n#{self.to_s}
\n#{self}
Global state `Time.zone` was leaked.
Expected: #{EXPECTED_ZONE}
Got: #{Time.zone}
MSG
end
if ActiveRecord::Base.default_timezone != EXPECTED_DEFAULT_TIMEZONE
$stderr.puts <<-MSG
\n#{self.to_s}
\n#{self}
Global state `ActiveRecord::Base.default_timezone` was leaked.
Expected: #{EXPECTED_DEFAULT_TIMEZONE}
Got: #{ActiveRecord::Base.default_timezone}
MSG
end
if ActiveRecord::Base.time_zone_aware_attributes != EXPECTED_TIME_ZONE_AWARE_ATTRIBUTES
$stderr.puts <<-MSG
\n#{self.to_s}
\n#{self}
Global state `ActiveRecord::Base.time_zone_aware_attributes` was leaked.
Expected: #{EXPECTED_TIME_ZONE_AWARE_ATTRIBUTES}
Got: #{ActiveRecord::Base.time_zone_aware_attributes}
Expand Down
2 changes: 1 addition & 1 deletion activesupport/test/json/encoding_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def as_json(options={})
[ 1.0/0.0, %(null) ],
[ -1.0/0.0, %(null) ],
[ BigDecimal('0.0')/BigDecimal('0.0'), %(null) ],
[ BigDecimal('2.5'), %("#{BigDecimal('2.5').to_s}") ]]
[ BigDecimal('2.5'), %("#{BigDecimal('2.5')}") ]]

StringTests = [[ 'this is the <string>', %("this is the \\u003cstring\\u003e")],
[ 'a "string" with quotes & an ampersand', %("a \\"string\\" with quotes \\u0026 an ampersand") ],
Expand Down

0 comments on commit 64b0982

Please sign in to comment.