Sha256: d3887580154514d2322a3207e10df779d5c3ae739519b06f24105b8396a06ebb

Contents?: true

Size: 1.87 KB

Versions: 1

Compression:

Stored size: 1.87 KB

Contents

require 'facets/module/mattr' # gives cattr

module SanitizeEmail
  class Config

    cattr_reader :config
    cattr_writer :config

    self.config ||= {
      # 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. "real@example.com <sanitized@example.com>"
      :use_actual_email_as_sanitized_user_name => false,

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

      :activation_proc => Proc.new { false }
    }
    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
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sanitize_email-1.0.2 lib/sanitize_email/config.rb