Class: Eyepaste::Mail::Interceptor

Inherits:
Object
  • Object
show all
Defined in:
lib/eyepaste-mail/interceptor.rb

Constant Summary collapse

@@white_list =
nil

Class Method Summary collapse

Class Method Details

.delivering_email(message) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/eyepaste-mail/interceptor.rb', line 18

def self.delivering_email(message)
  message.to = message[:to].addrs.map do |addr|
    email = addr.address
    on_white_list = get_white_list.any? { |regexp| regexp.match(email)}
    if !on_white_list
      munged_email = "#{email.gsub(/@/, '_')}@eyepaste.com"
      formatted_address = addr.format.gsub(email, munged_email)
    else
      formatted_address = addr.format
    end

    formatted_address
  end
end

.get_white_listObject



10
11
12
13
14
15
16
# File 'lib/eyepaste-mail/interceptor.rb', line 10

def self.get_white_list
  return [] if @@white_list.nil?

  white_list = @@white_list.kind_of?(Proc) ? @@white_list.call : @@white_list

  white_list.respond_to?(:each) ? white_list : [white_list]
end

.set_white_list(white_list = nil, &block) ⇒ Object



6
7
8
# File 'lib/eyepaste-mail/interceptor.rb', line 6

def self.set_white_list(white_list=nil, &block)
  @@white_list = block || white_list
end