Sha256: 006e4b73632db5ad2871fe19025bf5b7a016220e5fab02bd7bd1ec84201deeae

Contents?: true

Size: 1.09 KB

Versions: 37

Compression:

Stored size: 1.09 KB

Contents

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_ROOT",           "::Rails.root.to_s")
  DeprecatedConstant.deprecate("RAILS_ENV",            "::Rails.env")
  DeprecatedConstant.deprecate("RAILS_DEFAULT_LOGGER", "::Rails.logger")
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
railties-3.0.20 lib/rails/deprecation.rb
railties-3.0.19 lib/rails/deprecation.rb
railties-3.0.18 lib/rails/deprecation.rb
railties-3.0.17 lib/rails/deprecation.rb
railties-3.0.16 lib/rails/deprecation.rb
railties-3.0.15 lib/rails/deprecation.rb
railties-3.0.14 lib/rails/deprecation.rb
railties-3.0.13 lib/rails/deprecation.rb
railties-3.0.13.rc1 lib/rails/deprecation.rb
railties-3.0.12 lib/rails/deprecation.rb
railties-3.0.12.rc1 lib/rails/deprecation.rb
railties-3.0.11 lib/rails/deprecation.rb
railties-3.0.10 lib/rails/deprecation.rb
railties-3.0.10.rc1 lib/rails/deprecation.rb
railties-3.0.9 lib/rails/deprecation.rb
railties-3.0.9.rc5 lib/rails/deprecation.rb
railties-3.0.9.rc4 lib/rails/deprecation.rb
railties-3.0.9.rc3 lib/rails/deprecation.rb
railties-3.0.9.rc1 lib/rails/deprecation.rb
railties-3.0.8 lib/rails/deprecation.rb