diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2012-01-18 17:05:18 -0800 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2012-01-18 17:05:18 -0800 |
commit | b5134601adebd1dbebc18be35c5e5336011a023f (patch) | |
tree | 92b97e840ffdf25fbc6a6d0b615f81f93978197f /railties/lib | |
parent | d843a943b343023bcbaa9e34d912d2807927cacd (diff) | |
parent | 04d6ebb467a449a5b56151de5fb13c41318d217a (diff) | |
download | rails-b5134601adebd1dbebc18be35c5e5336011a023f.tar.gz rails-b5134601adebd1dbebc18be35c5e5336011a023f.tar.bz2 rails-b5134601adebd1dbebc18be35c5e5336011a023f.zip |
Merge pull request #4534 from lest/patch-1
refactor RAILS_CACHE deprecation
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/deprecation.rb | 37 |
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 |