A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://api.rubyonrails.org/classes/ActiveSupport/Deprecation/DeprecatedConstantProxy.html below:

Website Navigation


ActiveSupport::Deprecation::DeprecatedConstantProxy

DeprecatedConstantProxy transforms a constant into a deprecated one. It takes the full names of an old (deprecated) constant and of a new constant (both in string form) and a deprecator. The deprecated constant now returns the value of the new one.

PLANETS = %w(mercury venus earth mars jupiter saturn uranus neptune pluto)

# (In a later update, the original implementation of `PLANETS` has been removed.)

PLANETS_POST_2006 = %w(mercury venus earth mars jupiter saturn uranus neptune)
PLANETS = ActiveSupport::Deprecation::DeprecatedConstantProxy.new("PLANETS", "PLANETS_POST_2006", ActiveSupport::Deprecation.new)

PLANETS.map { |planet| planet.capitalize }
# => DEPRECATION WARNING: PLANETS is deprecated! Use PLANETS_POST_2006 instead.
     (Backtrace information…)
     ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"]

Methods

A
C
E
I
N
P
Class Public methods new(*args, **options, &block) Link

Source: show | on GitHub

def self.new(*args, **options, &block)
  object = args.first

  return object unless object
  super
end
new(old_const, new_const, deprecator, message: "#{old_const} is deprecated! Use #{new_const} instead.") Link

Source: show | on GitHub

def initialize(old_const, new_const, deprecator, message: "#{old_const} is deprecated! Use #{new_const} instead.")
  Kernel.require "active_support/inflector/methods"

  @old_const = old_const
  @new_const = new_const
  @deprecator = deprecator
  @message = message
end
Instance Public methods append_features(base) Link

Source: show | on GitHub

def append_features(base)
  @deprecator.warn(@message, caller_locations)
  base.include(target)
end
class() Link

Returns the class of the new constant.

PLANETS_POST_2006 = %w(mercury venus earth mars jupiter saturn uranus neptune)
PLANETS = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('PLANETS', 'PLANETS_POST_2006')
PLANETS.class # => Array
extended(base) Link

Source: show | on GitHub

def extended(base)
  @deprecator.warn(@message, caller_locations)
  base.extend(target)
end
inspect() Link

Don’t give a deprecation warning on inspect since test/unit and error logs rely on it for diagnostics.

prepend_features(base) Link

Source: show | on GitHub

def prepend_features(base)
  @deprecator.warn(@message, caller_locations)
  base.prepend(target)
end

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4