Skip to content
This repository
Browse code

refactor RAILS_CACHE deprecation

that was introduced in 6f8159c
  • Loading branch information...
commit 04d6ebb467a449a5b56151de5fb13c41318d217a 1 parent d843a94
Sergey Nartimov authored January 19, 2012

Showing 1 changed file with 8 additions and 29 deletions. Show diff stats Hide diff stats

  1. 37  railties/lib/rails/deprecation.rb
37  railties/lib/rails/deprecation.rb
... ...
@@ -1,39 +1,18 @@
1  
-require "active_support/string_inquirer"
2  
-require "active_support/basic_object"
  1
+require 'active_support/deprecation/proxy_wrappers'
3 2
 
4 3
 module Rails
5  
-  module Initializer
6  
-    def self.run(&block)
7  
-      klass = Class.new(Rails::Application)
8  
-      klass.instance_exec(klass.config, &block)
9  
-      klass.initialize!
10  
-    end
11  
-  end
12  
-
13  
-  class DeprecatedConstant < ActiveSupport::BasicObject
14  
-    def self.deprecate(old, new)
15  
-      constant = self.new(old, new)
  4
+  class DeprecatedConstant < ActiveSupport::Deprecation::DeprecatedConstantProxy
  5
+    def self.deprecate(old, current)
  6
+      constant = new(old, current)
16 7
       eval "::#{old} = constant"
17 8
     end
18 9
 
19  
-    def initialize(old, new)
20  
-      @old, @new = old, new
21  
-      @target = ::Kernel.eval "proc { #{@new} }"
22  
-      @warned = false
23  
-    end
24  
-
25  
-    def method_missing(meth, *args, &block)
26  
-      ::ActiveSupport::Deprecation.warn("#{@old} is deprecated. Please use #{@new}") unless @warned
27  
-      @warned = true
  10
+    private
28 11
 
29  
-      target = @target.call
30  
-      if target.respond_to?(meth)
31  
-        target.send(meth, *args, &block)
32  
-      else
33  
-        super
34  
-      end
  12
+    def target
  13
+      ::Kernel.eval @new_const.to_s
35 14
     end
36 15
   end
37 16
 
38  
-  DeprecatedConstant.deprecate("RAILS_CACHE", "::Rails.cache")
  17
+  DeprecatedConstant.deprecate('RAILS_CACHE', '::Rails.cache')
39 18
 end

0 notes on commit 04d6ebb

Please sign in to comment.
Something went wrong with that request. Please try again.