From 04d6ebb467a449a5b56151de5fb13c41318d217a Mon Sep 17 00:00:00 2001 From: Sergey Nartimov Date: Thu, 19 Jan 2012 02:20:32 +0300 Subject: refactor RAILS_CACHE deprecation that was introduced in 6f8159c4217dc8433a2027ced0c61e7ce94551d3 --- railties/lib/rails/deprecation.rb | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) (limited to 'railties/lib/rails') 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 -- cgit v1.2.3