diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-02-04 17:00:50 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-02-04 17:00:50 +0000 |
commit | 25b6b95459ae71218754e8469f77f86b676bf215 (patch) | |
tree | 33e85a84569fe0f74aa149ad4dfa6a0bf011b127 /railties/lib/rails | |
parent | 06860dcf29d73c0c4fbe5a42fde4db0ce9753937 (diff) | |
download | rails-25b6b95459ae71218754e8469f77f86b676bf215.tar.gz rails-25b6b95459ae71218754e8469f77f86b676bf215.tar.bz2 rails-25b6b95459ae71218754e8469f77f86b676bf215.zip |
Make RAILS_* give deprecation warning just once
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/deprecation.rb | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/railties/lib/rails/deprecation.rb b/railties/lib/rails/deprecation.rb index f28da5a6b0..1eb6d804b6 100644 --- a/railties/lib/rails/deprecation.rb +++ b/railties/lib/rails/deprecation.rb @@ -2,6 +2,9 @@ require "active_support/string_inquirer" require "active_support/deprecation" RAILS_ROOT = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do + cattr_accessor :warned + self.warned = false + def target Rails.root end @@ -11,12 +14,17 @@ RAILS_ROOT = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do end def warn(callstack, called, args) - msg = "RAILS_ROOT is deprecated! Use Rails.root instead" - ActiveSupport::Deprecation.warn(msg, callstack) + unless warned + ActiveSupport::Deprecation.warn("RAILS_ROOT is deprecated! Use Rails.root instead", callstack) + self.warned = true + end end end).new RAILS_ENV = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do + cattr_accessor :warned + self.warned = false + def target Rails.env end @@ -26,12 +34,17 @@ RAILS_ENV = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do end def warn(callstack, called, args) - msg = "RAILS_ENV is deprecated! Use Rails.env instead" - ActiveSupport::Deprecation.warn(msg, callstack) + unless warned + ActiveSupport::Deprecation.warn("RAILS_ENV is deprecated! Use Rails.env instead", callstack) + self.warned = true + end end end).new RAILS_DEFAULT_LOGGER = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do + cattr_accessor :warned + self.warned = false + def target Rails.logger end @@ -41,7 +54,9 @@ RAILS_DEFAULT_LOGGER = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) end def warn(callstack, called, args) - msg = "RAILS_DEFAULT_LOGGER is deprecated! Use Rails.logger instead" - ActiveSupport::Deprecation.warn(msg, callstack) + unless warned + ActiveSupport::Deprecation.warn("RAILS_DEFAULT_LOGGER is deprecated! Use Rails.logger instead", callstack) + self.warned = true + end end end).new |