lib/sanitize_email/config.rb in sanitize_email-1.0.2 vs lib/sanitize_email/config.rb in sanitize_email-1.0.3
- old
+ new
@@ -1,14 +1,13 @@
require 'facets/module/mattr' # gives cattr
module SanitizeEmail
class Config
- cattr_reader :config
- cattr_writer :config
+ extend SanitizeEmail::Deprecation
- self.config ||= {
+ DEFAULTS = {
# Specify the BCC addresses for the messages that go out in 'local' environments
:sanitized_bcc => nil,
# Specify the CC addresses for the messages that go out in 'local' environments
:sanitized_cc => nil,
@@ -31,10 +30,15 @@
# e.g. "real@example.com rest of subject"
:use_actual_email_prepended_to_subject => false,
:activation_proc => Proc.new { false }
}
+
+ cattr_reader :config
+ cattr_writer :config
+
+ self.config ||= DEFAULTS
def self.configure &block
yield @@config
# Gracefully handle deprecated config values.
# Actual deprecation warnings are thrown in the top SanitizeEmail module thanks to our use of dynamic methods.
@@ -44,9 +48,16 @@
if @@config[:sanitized_recipients]
SanitizeEmail.sanitized_recipients # calling it to trigger the deprecation warning.
#Won't actually be set with any value,
# because we are still inside the configure block.
@@config[:sanitized_to] = @@config[:sanitized_recipients]
+ end
+ if !@@config[:force_sanitize].nil?
+ replacement = "
+ Please use SanitizeEmail.force_sanitize or SanitizeEmail.sanitary instead.
+ Refer to https://github.com/pboling/sanitize_email/wiki for examples."
+ deprecation("SanitizeEmail::Config.config[:force_sanitize]", replacement)
+ SanitizeEmail.force_sanitize = @@config[:force_sanitize]
end
end
end
end