Skip to content

Commit

Permalink
Document NameError extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy committed Mar 25, 2009
1 parent 614fccd commit 3f7130a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions activesupport/lib/active_support/core_ext/name_error.rb
@@ -1,10 +1,9 @@
# Add a +missing_name+ method to NameError instances.
class NameError #:nodoc:
# Add a method to obtain the missing name from a NameError.
class NameError
# Extract the name of the missing constant from the exception message.
def missing_name
$1 if /((::)?([A-Z]\w*)(::[A-Z]\w*)*)$/ =~ message
end

# Was this exception raised because the given name was missing?
def missing_name?(name)
if name.is_a? Symbol
Expand Down

0 comments on commit 3f7130a

Please sign in to comment.