Sha256: 1e57e0f35d47f3505048a231ab719deb85e9a1a515956e007a89e4541ca7c3c9
Contents?: true
Size: 488 Bytes
Versions: 6
Compression:
Stored size: 488 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(*__rest__) = "" end end end
Version data entries
6 entries across 6 versions & 1 rubygems