module ActionRecipient::Rewriter

Public Class Methods

domain_for(email) click to toggle source
# File lib/action_recipient/rewriter.rb, line 45
def domain_for(email)
  email.split('@').last
end
format() click to toggle source
# File lib/action_recipient/rewriter.rb, line 41
def format
  ActionRecipient.config.format
end
match_with_any_whitelisted_addresses?(email) click to toggle source
# File lib/action_recipient/rewriter.rb, line 25
def match_with_any_whitelisted_addresses?(email)
  whitelist.addresses.any? { |string_or_regexp|
    string_or_regexp === email
  }
end
match_with_any_whitelisted_domains?(domain) click to toggle source
# File lib/action_recipient/rewriter.rb, line 31
def match_with_any_whitelisted_domains?(domain)
  whitelist.domains.any? { |string_or_regexp|
    string_or_regexp === domain
  }
end
rewrite(email, prefix, format) click to toggle source
# File lib/action_recipient/rewriter.rb, line 17
def rewrite(email, prefix, format)
  format % "#{prefix}#{email.gsub('@', '_at_').gsub(/[^\.\w]/, '-')}"
end
rewrite_addresses!(message, type, prefix: '') click to toggle source
# File lib/action_recipient/rewriter.rb, line 4
def rewrite_addresses!(message, type, prefix: '')
  address_container = message[type]&.field&.addrs
  return unless address_container

  message[type] = address_container.map { |address_object|
    if whitelisted?(address_object.address)
      address_object.to_s
    else
      rewrite(address_object.address, prefix, format)
    end
  }
end
whitelist() click to toggle source
# File lib/action_recipient/rewriter.rb, line 37
def whitelist
  ActionRecipient.config.whitelist
end
whitelisted?(email) click to toggle source
# File lib/action_recipient/rewriter.rb, line 21
def whitelisted?(email)
  match_with_any_whitelisted_addresses?(email) || match_with_any_whitelisted_domains?(domain_for(email))
end