blob: 71adcd61f4d8e0604221695c0077223b98fc3e76 (
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
|
require "active_support/string_inquirer"
require "active_support/basic_object"
module Rails
module Initializer
def self.run(&block)
klass = Class.new(Rails::Application)
klass.instance_exec(klass.config, &block)
klass.initialize!
end
end
class DeprecatedConstant < ActiveSupport::BasicObject
def self.deprecate(old, new)
constant = self.new(old, new)
eval "::#{old} = constant"
end
def initialize(old, new)
@old, @new = old, new
@target = ::Kernel.eval "proc { #{@new} }"
@warned = false
end
def method_missing(meth, *args, &block)
::ActiveSupport::Deprecation.warn("#{@old} is deprecated. Please use #{@new}") unless @warned
@warned = true
target = @target.call
if target.respond_to?(meth)
target.send(meth, *args, &block)
else
super
end
end
end
DeprecatedConstant.deprecate("RAILS_CACHE", "::Rails.cache")
end
|