Module: MList::List
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
-
#active? ⇒ Boolean
Answers whether this list is active or not.
-
#archive_url ⇒ Object
The web address where an archive of this list may be found, nil if there is no archive.
-
#been_here?(email) ⇒ Boolean
Answers whether the email has been to this list before.
-
#blocked?(subscriber) ⇒ Boolean
Answers whether the subscriber is blocked from posting or not.
-
#copy_sender?(subscriber) ⇒ Boolean
Should the sender of an email be copied in the publication? Defaults to false.
-
#footer_content(message) ⇒ Object
Answers the footer content for this list.
-
#help_url ⇒ Object
The web address of the list help site, nil if this is not supported.
-
#label ⇒ Object
Answer a suitable label for the list, which will be used in various parts of content that is delivered to subscribers, etc.
-
#list_headers ⇒ Object
Answers the headers that are to be included in the emails delivered for this list.
-
#list_id ⇒ Object
Answers a unique, never changing value for this list.
-
#owner_url ⇒ Object
The email address of the list owner, nil if this is not supported.
-
#post_url ⇒ Object
The email address where posts should be sent.
-
#recipients(subscriber) ⇒ Object
A list is responsible for answering the recipient subscribers.
-
#reply_to_list? ⇒ Boolean
Should the reply-to header be set to the list’s address? Defaults to true.
-
#subscribe_url ⇒ Object
The web url where subscriptions to this list may be created, nil if this is not supported.
-
#subscriber(email_address) ⇒ Object
A list must answer the subscriber who’s email address is that of the one provided.
-
#subscriber?(email_address) ⇒ Boolean
A list must answer whether there is a subscriber who’s email address is that of the one provided.
-
#unsubscribe_url ⇒ Object
The web url where subscriptions to this list may be deleted, nil if this is not supported.
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.
16 17 18 |
# File 'lib/mlist/list.rb', line 16 def active? true end |
#archive_url ⇒ Object
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.
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).
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.
84 85 86 |
# File 'lib/mlist/list.rb', line 84 def copy_sender?(subscriber) false end |
#footer_content(message) ⇒ Object
Answers the footer content for this list. Default implementation is very simple.
38 39 40 |
# File 'lib/mlist/list.rb', line 38 def () %Q{The "#{label}" mailing list\nPost messages: #{post_url}} end |
#help_url ⇒ Object
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 |
#label ⇒ Object
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_headers ⇒ Object
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_id ⇒ Object
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_url ⇒ Object
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_url ⇒ Object
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.
110 111 112 |
# File 'lib/mlist/list.rb', line 110 def reply_to_list? true end |
#subscribe_url ⇒ Object
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.
154 155 156 |
# File 'lib/mlist/list.rb', line 154 def subscriber?(email_address) !subscriber(email_address).nil? end |
#unsubscribe_url ⇒ Object
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 |