diff options
author | José Valim <jose.valim@gmail.com> | 2011-12-21 23:41:18 -0800 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-12-21 23:41:18 -0800 |
commit | 432c3661512389986349a1f4ba2b92362117cc30 (patch) | |
tree | abacaeda2bf35d7ddc8700508b3ed79848370ee5 /activesupport | |
parent | 667d7aa61d0c50be23ab24a4c16b8c9c9c0daff8 (diff) | |
parent | 4f6af26a886630c97865a2e5023a9560692e6aa4 (diff) | |
download | rails-432c3661512389986349a1f4ba2b92362117cc30.tar.gz rails-432c3661512389986349a1f4ba2b92362117cc30.tar.bz2 rails-432c3661512389986349a1f4ba2b92362117cc30.zip |
Merge pull request #4121 from lest/remove-whiny-nils
remove AS whiny nil extension and deprecate config.whiny_nils
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/railtie.rb | 6 | ||||
-rw-r--r-- | activesupport/lib/active_support/whiny_nil.rb | 22 | ||||
-rw-r--r-- | activesupport/test/whiny_nil_test.rb | 11 |
3 files changed, 0 insertions, 39 deletions
diff --git a/activesupport/lib/active_support/railtie.rb b/activesupport/lib/active_support/railtie.rb index 1638512af0..f696716cc8 100644 --- a/activesupport/lib/active_support/railtie.rb +++ b/activesupport/lib/active_support/railtie.rb @@ -5,12 +5,6 @@ module ActiveSupport class Railtie < Rails::Railtie config.active_support = ActiveSupport::OrderedOptions.new - # Loads support for "whiny nil" (noisy warnings when methods are invoked - # on +nil+ values) if Configuration#whiny_nils is true. - initializer "active_support.initialize_whiny_nils" do |app| - require 'active_support/whiny_nil' if app.config.whiny_nils - end - initializer "active_support.deprecation_behavior" do |app| if deprecation = app.config.active_support.deprecation ActiveSupport::Deprecation.behavior = deprecation diff --git a/activesupport/lib/active_support/whiny_nil.rb b/activesupport/lib/active_support/whiny_nil.rb deleted file mode 100644 index a065233679..0000000000 --- a/activesupport/lib/active_support/whiny_nil.rb +++ /dev/null @@ -1,22 +0,0 @@ -# Extensions to +nil+ which allow for more helpful error messages for people who -# are new to Rails. -# -# NilClass#id exists in Ruby 1.8 (though it is deprecated). Since +id+ is a fundamental -# method of Active Record models NilClass#id is redefined as well to raise a RuntimeError -# and warn the user. She probably wanted a model database identifier and the 4 -# returned by the original method could result in obscure bugs. -# -# The flag <tt>config.whiny_nils</tt> determines whether this feature is enabled. -# By default it is on in development and test modes, and it is off in production -# mode. -class NilClass - def self.add_whiner(klass) - ActiveSupport::Deprecation.warn "NilClass.add_whiner is deprecated and this functionality is " \ - "removed from Rails versions as it affects Ruby 1.9 performance.", caller - end - - # Raises a RuntimeError when you attempt to call +id+ on +nil+. - def id - raise RuntimeError, "Called id for nil, which would mistakenly be #{object_id} -- if you really wanted the id of nil, use object_id", caller - end -end diff --git a/activesupport/test/whiny_nil_test.rb b/activesupport/test/whiny_nil_test.rb deleted file mode 100644 index 8c1f1b2677..0000000000 --- a/activesupport/test/whiny_nil_test.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'abstract_unit' -require 'active_support/whiny_nil' - -class WhinyNilTest < Test::Unit::TestCase - def test_id - nil.id - rescue RuntimeError => nme - assert_no_match(/nil:NilClass/, nme.message) - assert_match(Regexp.new(nil.object_id.to_s), nme.message) - end -end |