Sha256: 37dcf41d2a7b7ac4024640ce4af720bd41dd8a1bc6670efd8600c80880cf4e85

Contents?: true

Size: 502 Bytes

Versions: 67

Compression:

Stored size: 502 Bytes

Contents

# Add a +missing_name+ method to NameError instances.
class NameError < StandardError #:nodoc:  
  # Add a method to obtain the missing name from a NameError.
  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
      last_name = (missing_name || '').split('::').last
      last_name == name.to_s
    else
      missing_name == name.to_s
    end
  end
end

Version data entries

67 entries across 67 versions & 4 rubygems

Version Path
activesupport-1.4.4 lib/active_support/core_ext/name_error.rb
activesupport-1.4.3 lib/active_support/core_ext/name_error.rb
activesupport-1.4.1 lib/active_support/core_ext/name_error.rb
activesupport-1.4.2 lib/active_support/core_ext/name_error.rb
backlog-0.0.0 vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb
backlog-0.0.1 vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb
backlog-0.0.2 vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb
backlog-0.0.5 vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb
backlog-0.0.4 vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb
backlog-0.1.0 vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb
backlog-0.1.1 vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb
backlog-0.1.2 vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb
backlog-0.2.0 vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb
backlog-0.2.1 vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb
backlog-0.3.0 vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb
backlog-0.3.3 vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb
backlog-0.3.1 vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb
backlog-0.3.2 vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb
backlog-0.3.4 vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb
backlog-0.3.5 vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb