15
16
17
18
19
20
21
22
23
24
|
# File 'lib/bracket_error_suggestion/nil_ext.rb', line 15
def method_missing_with_be_suggestion(name, *args, &block)
return method_missing_without_be_suggestion(name, *args, &block) unless BracketErrorSuggestion.enabled
case name
when :[] then
key = args.first
raise NoMethodError, "undefined method `[]' for nil:NilClass, maybe it attempted to access: " +
BracketErrorSuggestion.nil_parent_paths.reverse.map{|path| "#{path}[#{key.inspect}] but #{path} is nil"}.join(", ")
end
return method_missing_without_be_suggestion(name, *args, &block)
end
|