class NoMethodError

Usage:

require 'may_nil'

Examples:

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

Public Instance Methods

may_nil_missing_source() click to toggle source
# 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