From ca9413674ea70dc67ab517734af2e40dac21beef Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Wed, 26 Mar 2008 12:27:52 +0000 Subject: Improve documentation. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9093 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/whiny_nil.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activesupport/lib/active_support/whiny_nil.rb') diff --git a/activesupport/lib/active_support/whiny_nil.rb b/activesupport/lib/active_support/whiny_nil.rb index f614b41fc7..983a14fd42 100644 --- a/activesupport/lib/active_support/whiny_nil.rb +++ b/activesupport/lib/active_support/whiny_nil.rb @@ -18,6 +18,7 @@ class NilClass methods.each { |method| @@method_class_map[method.to_sym] = class_name } end + # Raises a RuntimeError when you attempt to call id on nil or a nil object. def id raise RuntimeError, "Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id", caller end @@ -27,6 +28,7 @@ class NilClass raise_nil_warning_for @@method_class_map[method], method, caller end + # Raises a NoMethodError when you attempt to call a method on nil, or a nil object. def raise_nil_warning_for(class_name = nil, selector = nil, with_caller = nil) message = "You have a nil object when you didn't expect it!" message << "\nYou might have expected an instance of #{class_name}." if class_name -- cgit v1.2.3