Sha256: 017763017c5dc2b93ff05e0877c46ee1c28593191c2344f751513a4c515be033

Contents?: true

Size: 578 Bytes

Versions: 2

Compression:

Stored size: 578 Bytes

Contents

# frozen_string_literal: true

require_relative "exceptions_base"

module Exceptions
  class NameError < ExceptionsBase
    private

    def unknown_from_exception
      exception.to_s.split.last
    end

    def corrected_word
      @corrected_word ||= spell_checker(ar_models_dictionary).correct(unknown_from_exception).first
    end

    def corrected_cmd
      @corrected_cmd ||= last_cmd.gsub(unknown_from_exception, corrected_word)
    end

    def ar_models_dictionary
      @ar_models_dictionary ||= store.transaction { |s| s["active_record_models"] }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pry-byetypo-1.0.2 lib/pry-byetypo/exceptions/name_error.rb
pry-byetypo-1.0.0 lib/pry-byetypo/exceptions/name_error.rb