Sha256: 12fb6e9a2f4b5a32a8239cafe526ab746605710797d1dc2ea8a7c9bdd4851f35
Contents?: true
Size: 486 Bytes
Versions: 15
Compression:
Stored size: 486 Bytes
Contents
# frozen_string_literal: true module ActionPolicy # Adds `suggest` method which uses did_you_mean # to generate a suggestion message module SuggestMessage if defined?(::DidYouMean::SpellChecker) def suggest(needle, heystack) suggestion = ::DidYouMean::SpellChecker.new( dictionary: heystack ).correct(needle).first suggestion ? "\nDid you mean? #{suggestion}" : "" end else def suggest(*) ; ""; end end end end
Version data entries
15 entries across 15 versions & 1 rubygems