aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/deprecation.rb
blob: 1eb6d804b61d82fbcf4fc5da4f4664645ab692c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require "active_support/string_inquirer"
require "active_support/deprecation"

RAILS_ROOT = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do
  cattr_accessor :warned
  self.warned = false

  def target
    Rails.root
  end

  def replace(*args)
    warn(caller, :replace, *args)
  end

  def warn(callstack, called, args)
    unless warned
      ActiveSupport::Deprecation.warn("RAILS_ROOT is deprecated! Use Rails.root instead", callstack)
      self.warned = true
    end
  end
end).new

RAILS_ENV = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do
  cattr_accessor :warned
  self.warned = false

  def target
    Rails.env
  end

  def replace(*args)
    warn(caller, :replace, *args)
  end

  def warn(callstack, called, args)
    unless warned
      ActiveSupport::Deprecation.warn("RAILS_ENV is deprecated! Use Rails.env instead", callstack)
      self.warned = true
    end
  end
end).new

RAILS_DEFAULT_LOGGER = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do
  cattr_accessor :warned
  self.warned = false

  def target
    Rails.logger
  end

  def replace(*args)
    warn(caller, :replace, *args)
  end

  def warn(callstack, called, args)
    unless warned
      ActiveSupport::Deprecation.warn("RAILS_DEFAULT_LOGGER is deprecated! Use Rails.logger instead", callstack)
      self.warned = true
    end
  end
end).new