Skip to content

Commit

Permalink
Handle class method error
Browse files Browse the repository at this point in the history
  • Loading branch information
morissetcl committed Dec 30, 2024
1 parent 3d09600 commit 251846b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/pry-byetypo/exceptions/no_method_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ def dictionary
# Early return because built_in class does not have access to `instance_methods`.
return klass_methods.map(&:to_s) if built_in_klass


instance_methods = eval(infer_klass).instance_methods(false) # rubocop:disable Security/Eval
instance_methods.push(klass_methods).flatten.map(&:to_s)
instance_methods.push(klass_methods)
.push(ActiveRecord::Base.methods)
.flatten
.map(&:to_s)
end

def exception_regexp
Expand All @@ -29,6 +33,7 @@ def exception_regexp

def klass_regexp
return /for an instance of (\w+)/ if instance_exception?
return /for class (\w+)/ if exception.to_s.include?("class")

/for #<(\w+)/
end
Expand Down

0 comments on commit 251846b

Please sign in to comment.