Skip to content
Newer
Older
100644 19 lines (17 sloc) 496 Bytes
3f7130a @jeremy Document NameError extensions
jeremy authored Mar 24, 2009
1 class NameError
2 # Extract the name of the missing constant from the exception message.
196fab9 @seckar Add extention to obtain the missing constant from NameError instances
seckar authored Aug 5, 2006
3 def missing_name
9acc824 @jeremy Ruby 1.9.2: disallow explicit coercion via method_missing. Only give …
jeremy authored Nov 13, 2009
4 if /undefined local variable or method/ !~ message
5 $1 if /((::)?([A-Z]\w*)(::[A-Z]\w*)*)$/ =~ message
6 end
196fab9 @seckar Add extention to obtain the missing constant from NameError instances
seckar authored Aug 5, 2006
7 end
3f7130a @jeremy Document NameError extensions
jeremy authored Mar 25, 2009
8
196fab9 @seckar Add extention to obtain the missing constant from NameError instances
seckar authored Aug 5, 2006
9 # Was this exception raised because the given name was missing?
10 def missing_name?(name)
52d4166 @seckar Raise fully qualified names upon name errors. Closes #5533.
seckar authored Aug 5, 2006
11 if name.is_a? Symbol
12 last_name = (missing_name || '').split('::').last
13 last_name == name.to_s
14 else
15 missing_name == name.to_s
16 end
196fab9 @seckar Add extention to obtain the missing constant from NameError instances
seckar authored Aug 5, 2006
17 end
041b9b8 @jeremy Some 1.9 forward compatibility
jeremy authored Sep 14, 2007
18 end
Something went wrong with that request. Please try again.