File: active_support/core_ext/name_error.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: <Built-in Module>
  class: NameError#2
inherits from
  Object ( Builtin-Module )
has properties
method: missing_name #4
method: missing_name? / 1 #11

Class Hierarchy

Object ( Builtin-Module )
  NameError    #2

Code

   1  # Add a +missing_name+ method to NameError instances.
   2  class NameError #:nodoc:  
   3    # Add a method to obtain the missing name from a NameError.
   4    def missing_name
   5      if /undefined local variable or method/ !~ message
   6        $1 if /((::)?([A-Z]\w*)(::[A-Z]\w*)*)$/ =~ message
   7      end
   8    end
   9    
  10    # Was this exception raised because the given name was missing?
  11    def missing_name?(name)
  12      if name.is_a? Symbol
  13        last_name = (missing_name || '').split('::').last
  14        last_name == name.to_s
  15      else
  16        missing_name == name.to_s
  17      end
  18    end
  19  end