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 :email_address. 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.
-
#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.
66 67 68 |
# File 'lib/mlist/list.rb', line 66 def archive_url nil 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).
23 24 25 |
# File 'lib/mlist/list.rb', line 23 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.
76 77 78 |
# File 'lib/mlist/list.rb', line 76 def copy_sender?(subscriber) false end |
#footer_content(message) ⇒ Object
Answers the footer content for this list. Default implementation is very simple.
30 31 32 |
# File 'lib/mlist/list.rb', line 30 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.
82 83 84 |
# File 'lib/mlist/list.rb', line 82 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.
37 38 39 |
# File 'lib/mlist/list.rb', line 37 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.
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/mlist/list.rb', line 45 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.
59 60 61 |
# File 'lib/mlist/list.rb', line 59 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.
88 89 90 |
# File 'lib/mlist/list.rb', line 88 def owner_url nil end |
#post_url ⇒ Object
The email address where posts should be sent. Defaults to the address of the list.
95 96 97 |
# File 'lib/mlist/list.rb', line 95 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.
127 128 129 |
# File 'lib/mlist/list.rb', line 127 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.
102 103 104 |
# File 'lib/mlist/list.rb', line 102 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.
109 110 111 |
# File 'lib/mlist/list.rb', line 109 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.email_address == email_address. Your implementation should probably select just one record.
136 137 138 |
# File 'lib/mlist/list.rb', line 136 def subscriber(email_address) subscribers.detect {|s| s.email_address == 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.
146 147 148 |
# File 'lib/mlist/list.rb', line 146 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.
116 117 118 |
# File 'lib/mlist/list.rb', line 116 def unsubscribe_url nil end |