summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/did_you_mean.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/did_you_mean.rb b/lib/did_you_mean.rb
index 0aef324059..9a77c8ebe7 100644
--- a/lib/did_you_mean.rb
+++ b/lib/did_you_mean.rb
@@ -114,8 +114,28 @@ module DidYouMean
correct_error NoMatchingPatternKeyError, PatternKeyNameChecker if defined?(::NoMatchingPatternKeyError)
# TODO: Remove on 3.3:
- SPELL_CHECKERS = @spell_checkers
+ class DeprecatedMapping # :nodoc:
+ def []=(key, value)
+ warn "Calling `DidYouMean::SPELL_CHECKERS[#{key.to_s}] = #{value.to_s}' has been deprecated. " \
+ "Please call `DidYouMean.correct_error(#{key.to_s}, #{value.to_s})' instead."
+
+ DidYouMean.correct_error(key, value)
+ end
+
+ def merge!(hash)
+ warn "Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. " \
+ "Please call `DidYouMean.correct_error(error_name, spell_checker)' instead."
+
+ hash.each do |error_class, spell_checker|
+ DidYouMean.correct_error(error_class, spell_checker)
+ end
+ end
+ end
+
+ # TODO: Remove on 3.3:
+ SPELL_CHECKERS = DeprecatedMapping.new
deprecate_constant :SPELL_CHECKERS
+ private_constant :DeprecatedMapping
# Returns the currently set formatter. By default, it is set to +DidYouMean::Formatter+.
def self.formatter