Exception: NoMethodError

Inherits:
Exception
  • Object
show all
Defined in:
lib/may_nil.rb

Overview

Usage:

require 'may_nil'

Examples:

may_nil{ nil.foo.bar[2].baz } => nil
may_nil{ 0.foo.bar[2].baz   } => Exception: NoMethodError

Instance Method Summary collapse

Instance Method Details

#may_nil_missing_sourceObject



11
12
13
14
15
# File 'lib/may_nil.rb', line 11

def may_nil_missing_source
  if /undefined local variable or method/ !~ message
    $1 if /((::)?([A-Z]\w*)(::[A-Z]\w*)*)$/ =~ message
  end
end