Sha256: b34d84979cd1b03a07199301317dffc6b07234817b31a82a5b67ab733b6913f8

Contents?: true

Size: 596 Bytes

Versions: 1

Compression:

Stored size: 596 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

    yield if block

    warn(message) if active?
  end

  def behavior
    ActiveSupport::Deprecation.behavior
  end

  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.1.0 lib/delayed_deprecation.rb