Module: MList::List

Includes:
Callbacks
Included in:
Manager::Database::List
Defined in:
lib/mlist/list.rb

Overview

Represents the interface of the lists that a list manager must answer. This is distinct from the MList::MailList to allow for greater flexibility in processing email coming to a list - that is, whatever you include this into may re-define behavior appropriately.

Your ‘subscriber’ instances MUST respond to :rfc5322_email. They may optionally respond to :display_name.

Defined Under Namespace

Modules: Callbacks

Instance Method Summary collapse

Methods included from Callbacks

#blocked_subscriber_post, #bounce, #inactive_post, #non_subscriber_post

Instance Method Details

#active?Boolean

Answers whether this list is active or not. All lists are active all the time by default.

Returns:

  • (Boolean)


16
17
18
# File 'lib/mlist/list.rb', line 16

def active?
  true
end

#archive_urlObject

The web address where an archive of this list may be found, nil if there is no archive.



74
75
76
# File 'lib/mlist/list.rb', line 74

def archive_url
  nil
end

#been_here?(email) ⇒ Boolean

Answers whether the email has been to this list before. The simplest test is whether the email has an X-BeenThere header that matches this list’s address.

Returns:

  • (Boolean)


24
25
26
# File 'lib/mlist/list.rb', line 24

def been_here?(email)
  email.been_there_addresses.include?(address.downcase)
end

#blocked?(subscriber) ⇒ Boolean

Answers whether the subscriber is blocked from posting or not. This will not be asked when the list is not active (answers active? as false).

Returns:

  • (Boolean)


31
32
33
# File 'lib/mlist/list.rb', line 31

def blocked?(subscriber)
  false
end

#copy_sender?(subscriber) ⇒ Boolean

Should the sender of an email be copied in the publication? Defaults to false. If recipients includes the sender email address, it will be removed if this answers false.

The sending subscriber is provided to support preferential answering.

Returns:

  • (Boolean)


84
85
86
# File 'lib/mlist/list.rb', line 84

def copy_sender?(subscriber)
  false
end

Answers the footer content for this list. Default implementation is very simple.



38
39
40
# File 'lib/mlist/list.rb', line 38

def footer_content(message)
  %Q{The "#{label}" mailing list\nPost messages: #{post_url}}
end

#help_urlObject

The web address of the list help site, nil if this is not supported.



90
91
92
# File 'lib/mlist/list.rb', line 90

def help_url
  nil
end

#labelObject

Answer a suitable label for the list, which will be used in various parts of content that is delivered to subscribers, etc.



45
46
47
# File 'lib/mlist/list.rb', line 45

def label
  raise 'answer the list label'
end

#list_headersObject

Answers the headers that are to be included in the emails delivered for this list. Any entries that have a nil value will not be included in the delivered email.



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/mlist/list.rb', line 53

def list_headers
  {
    'list-id'          => list_id,
    'list-archive'     => archive_url,
    'list-subscribe'   => subscribe_url,
    'list-unsubscribe' => unsubscribe_url,
    'list-owner'       => owner_url,
    'list-help'        => help_url,
    'list-post'        => post_url
  }
end

#list_idObject

Answers a unique, never changing value for this list.



67
68
69
# File 'lib/mlist/list.rb', line 67

def list_id
  raise 'answer a unique, never changing value'
end

#owner_urlObject

The email address of the list owner, nil if this is not supported.



96
97
98
# File 'lib/mlist/list.rb', line 96

def owner_url
  nil
end

#post_urlObject

The email address where posts should be sent. Defaults to the address of the list.



103
104
105
# File 'lib/mlist/list.rb', line 103

def post_url
  address
end

#recipients(subscriber) ⇒ Object

A list is responsible for answering the recipient subscribers. The answer may or may not include the subscriber; copy_sender? will be invoked and the subscriber will be added or removed from the Array.

The sending subscriber is provided if the list would like to utilize it in calculating the recipients.



135
136
137
# File 'lib/mlist/list.rb', line 135

def recipients(subscriber)
  subscribers
end

#reply_to_list?Boolean

Should the reply-to header be set to the list’s address? Defaults to true. If false is returned, the reply-to will be the subscriber address.

Returns:

  • (Boolean)


110
111
112
# File 'lib/mlist/list.rb', line 110

def reply_to_list?
  true
end

#subscribe_urlObject

The web url where subscriptions to this list may be created, nil if this is not supported.



117
118
119
# File 'lib/mlist/list.rb', line 117

def subscribe_url
  nil
end

#subscriber(email_address) ⇒ Object

A list must answer the subscriber who’s email address is that of the one provided. The default implementation will pick the first instance that answers subscriber.rfc5322_email == email_address. Your implementation should probably select just one record.



144
145
146
# File 'lib/mlist/list.rb', line 144

def subscriber(email_address)
  subscribers.detect {|s| s.rfc5322_email == email_address}
end

#subscriber?(email_address) ⇒ Boolean

A list must answer whether there is a subscriber who’s email address is that of the one provided. This is checked before the subscriber is requested in order to allow for the lightest weight check possible; that is, your implementation could avoid loading the actual subscriber instance.

Returns:

  • (Boolean)


154
155
156
# File 'lib/mlist/list.rb', line 154

def subscriber?(email_address)
  !subscriber(email_address).nil?
end

#unsubscribe_urlObject

The web url where subscriptions to this list may be deleted, nil if this is not supported.



124
125
126
# File 'lib/mlist/list.rb', line 124

def unsubscribe_url
  nil
end