Sha256: 235a1384c7c12adc97f87559d7f6ac9e0c7eb755db4be036135c429badf3d6a3

Contents?: true

Size: 834 Bytes

Versions: 1

Compression:

Stored size: 834 Bytes

Contents

# frozen_string_literal: true
module BitBucket
  DEPRECATION_PREFIX = '[BitBucketAPI] Deprecation warning:'

  class << self
    attr_writer :deprecation_tracker

    def deprecation_tracker
      @deprecation_tracker ||= []
    end

    # Displays deprecation message to the user.
    # Each message is printed once.
    def deprecate(method, alternate_method = nil)
      return if deprecation_tracker.include? method

      deprecation_tracker << method

      message = <<~NOTICE
        #{DEPRECATION_PREFIX}

        * #{method} is deprecated.
      NOTICE
      if alternate_method
        message << <<~ADDITIONAL
          * please use #{alternate_method} instead.
        ADDITIONAL
      end
      warn_deprecation(message)
    end

    def warn_deprecation(message)
      send :warn, message
    end
  end
end # BitBucket

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bitbuckets-0.2.0 lib/bitbucket_rest_api/deprecation.rb