Sha256: 96baefaf9d4aa04fcae683114181bb9763a01768a32a26868052bca1334749a8

Contents?: true

Size: 961 Bytes

Versions: 3

Compression:

Stored size: 961 Bytes

Contents

# frozen_string_literal: true

require 'active_support'
require 'active_support/deprecation'
require 'active_support/number_helper'
require 'bigdecimal'
require 'forwardable'

String.class_eval do
  include ActiveSupport::NumberHelper

  # Converts a number to a delimited number string
  # @see ActiveSupport::NumberHelper#number_to_delimited
  #
  # @param options [Hash]
  #
  # @return [String]
  #
  def to_delimited(options = {})
    number_to_delimited(self, options)
  end

  # Adding this alias to follow {ActionView::Helpers::NumberHelper#number_with_delimiter}
  alias_method :with_delimiter, :to_delimited

  # @deprecated This alias is only for Atlas and will be removed in future versions
  alias_method :with_sep, :to_delimited

  deprecate :with_sep, deprecator: ActiveSupport::Deprecation.new('3.0', 'ruby-rails-extensions')
end

Numeric.class_eval do
  extend Forwardable

  def_delegators :to_s, :to_delimited, :with_delimiter, :with_sep
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-rails-extensions-2.1.1 lib/ruby-rails-extensions/extensions/to_delimited.rb
ruby-rails-extensions-2.1.0 lib/ruby-rails-extensions/extensions/to_delimited.rb
ruby-rails-extensions-2.1.0.pre.rc.14 lib/ruby-rails-extensions/extensions/to_delimited.rb