Sha256: d7f5d48732c9ae14788c9e898553e14af5290334b31f604dc4e1a4d606e190a1

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

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_fs(#{format.inspect}) instead."
        )
        formatter.call(first, last)
      elsif format == NOT_SET
        if formatter = RangeWithFormat::RANGE_FORMATS[:default]
          ActiveSupport::Deprecation.warn(
            "Using a :default format for Range#to_s is deprecated. Please use Range#to_fs instead."
          )
          formatter.call(first, last)
        else
          super()
        end
      else
        ActiveSupport::Deprecation.warn(
          "Range#to_s(#{format.inspect}) is deprecated. Please use Range#to_fs(#{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

3 entries across 3 versions & 1 rubygems

Version Path
activesupport-7.0.7.2 lib/active_support/core_ext/range/deprecated_conversions.rb
activesupport-7.0.7.1 lib/active_support/core_ext/range/deprecated_conversions.rb
activesupport-7.0.7 lib/active_support/core_ext/range/deprecated_conversions.rb