Sha256: 9e0681cfb64a3d755d6b342e39aa6e6f5c64a067c36e883759f91751d32eb42e

Contents?: true

Size: 676 Bytes

Versions: 1

Compression:

Stored size: 676 Bytes

Contents

require "rubygems"
require "delayed_deprecation/version"
require "active_support/deprecation"

class DelayedDeprecation
  include ActiveSupport::Deprecation::Reporting

  def initialize(reason, owner:, reconsider_after: nil, &block)
    @reason = reason
    @owner = owner
    @reconsider_after = reconsider_after
    @deprecation_horizon = reconsider_after

    yield if block

    warn(message) if active?
  end

  def behavior
    ActiveSupport::Deprecation.behavior
  end

  attr_reader :deprecation_horizon

  private

  def active?(date = Date.today)
    !@reconsider_after || @reconsider_after <= date
  end

  def message
    "#{@reason} [Owner: #{@owner}]"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
delayed_deprecation-0.2.0 lib/delayed_deprecation.rb