Class: SanitizeEmail::Config

Inherits:
Object
  • Object
show all
Extended by:
Deprecation
Defined in:
lib/sanitize_email/config.rb

Constant Summary collapse

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,

  # The recipient addresses for the messages, either as a string (for a single
  # address) or an array (for multiple addresses) that go out in 'local' environments
  :sanitized_to => nil,

  # a white list
  :good_list => nil,

  # a black list
  :bad_list => nil,

  # Use the 'real' email address as the username for the sanitized email address
  # e.g. "[email protected] <[email protected]>"
  :use_actual_email_as_sanitized_user_name => false,

  # Prepend the 'real' email address onto the Subject line of the message
  # e.g. "[email protected] rest of subject"
  :use_actual_email_prepended_to_subject => false,

  # Prepend the Rails environment onto the Subject line of the message
  # e.g. "[development] rest of subject"
  :use_actual_environment_prepended_to_subject => false,

  :activation_proc => Proc.new { false }
}

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Deprecation

deprecated, deprecated_alias, deprecation

Class Attribute Details

.configObject

Returns the value of attribute config.



7
8
9
# File 'lib/sanitize_email/config.rb', line 7

def config
  @config
end

Class Method Details

.configure {|@config| ... } ⇒ Object

Yields:



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/sanitize_email/config.rb', line 43

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.
  if @config[:local_environments] && defined?(Rails)
    @config[:activation_proc] = Proc.new { SanitizeEmail.local_environments.include?(Rails.env) }
  end
  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