Class: MList::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/mlist/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Server

Returns a new instance of Server.



5
6
7
8
9
10
# File 'lib/mlist/server.rb', line 5

def initialize(config)
  @list_manager = config[:list_manager]
  @email_server = config[:email_server]
  @notifier = MList::Manager::Notifier.new
  @email_server.receiver(self)
end

Instance Attribute Details

#email_serverObject (readonly)

Returns the value of attribute email_server.



3
4
5
# File 'lib/mlist/server.rb', line 3

def email_server
  @email_server
end

#list_managerObject (readonly)

Returns the value of attribute list_manager.



3
4
5
# File 'lib/mlist/server.rb', line 3

def list_manager
  @list_manager
end

#notifierObject (readonly)

Returns the value of attribute notifier.



3
4
5
# File 'lib/mlist/server.rb', line 3

def notifier
  @notifier
end

Instance Method Details

#mail_list(list) ⇒ Object



23
24
25
# File 'lib/mlist/server.rb', line 23

def mail_list(list)
  MailList.find_or_create_by_list(list, @email_server)
end

#receive_email(email) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/mlist/server.rb', line 12

def receive_email(email)
  lists = list_manager.lists(email)
  if lists.empty?
    list_manager.no_lists_found(email)
  elsif email.bounce?
    process_bounce(lists.first, email)
  else
    process_post(lists, email)
  end
end