Sha256: 011d6f10deb1224e344fd91f2d72ea7b9aede5696ad33095a3c1d2ba0ea6d6bd

Contents?: true

Size: 819 Bytes

Versions: 5

Compression:

Stored size: 819 Bytes

Contents

# frozen_string_literal: true

module ActiveSupport
  module DeprecatedRangeWithFormat # :nodoc:
    NOT_SET = Object.new # :nodoc:
    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
    alias_method :to_default_s, :to_s
    deprecate :to_default_s
  end
end

Range.prepend(ActiveSupport::DeprecatedRangeWithFormat)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
activesupport-7.0.1 lib/active_support/core_ext/range/deprecated_conversions.rb
activesupport-7.0.0 lib/active_support/core_ext/range/deprecated_conversions.rb
activesupport-7.0.0.rc3 lib/active_support/core_ext/range/deprecated_conversions.rb
activesupport-7.0.0.rc2 lib/active_support/core_ext/range/deprecated_conversions.rb
activesupport-7.0.0.rc1 lib/active_support/core_ext/range/deprecated_conversions.rb