aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails
diff options
context:
space:
mode:
authorSergey Nartimov <just.lest@gmail.com>2012-01-19 02:20:32 +0300
committerSergey Nartimov <just.lest@gmail.com>2012-01-19 02:20:32 +0300
commit04d6ebb467a449a5b56151de5fb13c41318d217a (patch)
tree92b97e840ffdf25fbc6a6d0b615f81f93978197f /railties/lib/rails
parentd843a943b343023bcbaa9e34d912d2807927cacd (diff)
downloadrails-04d6ebb467a449a5b56151de5fb13c41318d217a.tar.gz
rails-04d6ebb467a449a5b56151de5fb13c41318d217a.tar.bz2
rails-04d6ebb467a449a5b56151de5fb13c41318d217a.zip
refactor RAILS_CACHE deprecation
that was introduced in 6f8159c4217dc8433a2027ced0c61e7ce94551d3
Diffstat (limited to 'railties/lib/rails')
-rw-r--r--railties/lib/rails/deprecation.rb37
1 files changed, 8 insertions, 29 deletions
diff --git a/railties/lib/rails/deprecation.rb b/railties/lib/rails/deprecation.rb
index 71adcd61f4..c5811b2629 100644
--- a/railties/lib/rails/deprecation.rb
+++ b/railties/lib/rails/deprecation.rb
@@ -1,39 +1,18 @@
-require "active_support/string_inquirer"
-require "active_support/basic_object"
+require 'active_support/deprecation/proxy_wrappers'
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)
+ class DeprecatedConstant < ActiveSupport::Deprecation::DeprecatedConstantProxy
+ def self.deprecate(old, current)
+ constant = new(old, current)
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
+ private
- target = @target.call
- if target.respond_to?(meth)
- target.send(meth, *args, &block)
- else
- super
- end
+ def target
+ ::Kernel.eval @new_const.to_s
end
end
- DeprecatedConstant.deprecate("RAILS_CACHE", "::Rails.cache")
+ DeprecatedConstant.deprecate('RAILS_CACHE', '::Rails.cache')
end