Module: ActiveSupport::DeprecatedRangeWithFormat

Included in:
Range
Defined in:
lib/active_support/core_ext/range/deprecated_conversions.rb

Overview

:nodoc:

Constant Summary collapse

NOT_SET =

:nodoc:

Object.new

Instance Method Summary collapse

Instance Method Details

#to_s(format = NOT_SET) ⇒ Object Also known as: to_default_s



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/active_support/core_ext/range/deprecated_conversions.rb', line 6

def to_s(format = NOT_SET)
  if formatter = RangeWithFormat::RANGE_FORMATS[format]
    ActiveSupport::Deprecation.warn(
      "Range#to_s(#{format.inspect}) is deprecated. Please use Range#to_formatted_s(#{format.inspect}) instead."
    )
    formatter.call(first, last)
  elsif format == NOT_SET
    super()
  else
    ActiveSupport::Deprecation.warn(
      "Range#to_s(#{format.inspect}) is deprecated. Please use Range#to_formatted_s(#{format.inspect}) instead."
    )
    super()
  end
end